diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..d581c29d --- /dev/null +++ b/.dockerignore @@ -0,0 +1 @@ +conf/appsettings.yaml diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..90903d84 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,27 @@ +## build +FROM golang:1.22.0-alpine3.19 AS build-env + +RUN apk add build-base + +ADD . /go/src/app + +WORKDIR /go/src/app + +RUN go env -w GO111MODULE=on \ + && go mod tidy \ + && cd ./cmd/server \ + && go build -o ../../relay + +## run +FROM alpine:3.19 + +RUN mkdir -p /ep && mkdir -p /ep/log + +WORKDIR /ep + +COPY --from=build-env /go/src/app /ep/ + +ENV PATH $PATH:/aa + +EXPOSE 80 +CMD ["/ep/relay"] diff --git a/conf/conf.go b/conf/conf.go index 46e200e1..9e85f880 100644 --- a/conf/conf.go +++ b/conf/conf.go @@ -28,7 +28,11 @@ func getConf() *Conf { // getConfiguration func getConfiguration(filePath *string) *Conf { if file, err := os.ReadFile(*filePath); err != nil { - return mappingEnvToConf(nil) + return mappingEnvToConf( + &Conf{ + Jwt: JWT{}, + }, + ) } else { c := Conf{} err := yaml.Unmarshal(file, &c) @@ -44,6 +48,15 @@ func mappingEnvToConf(conf *Conf) *Conf { // TODO: read from env // e.g. if dummy := os.Getenv("dummy"); len(dummy) > 0 {conf.Dummy = dummy} + if jwt__security := os.Getenv("jwt__security"); len(jwt__security) > 0 { + conf.Jwt.Security = jwt__security + } + if jwt__realm := os.Getenv("jwt__realm"); len(jwt__realm) > 0 { + conf.Jwt.Security = jwt__realm + } + if jwt__idkey := os.Getenv("jwt__idkey"); len(jwt__idkey) > 0 { + conf.Jwt.Security = jwt__idkey + } return conf }