Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chao/cicd #14

Merged
merged 5 commits into from
Mar 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
conf/appsettings.yaml
27 changes: 27 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
15 changes: 14 additions & 1 deletion conf/conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
}
Loading