Skip to content

Commit

Permalink
Merge pull request #14 from AAStarCommunity/chao/cicd
Browse files Browse the repository at this point in the history
Chao/cicd
  • Loading branch information
fanhousanbu committed Mar 4, 2024
2 parents bf89c3c + c486d0a commit a8c8b72
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
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
}

0 comments on commit a8c8b72

Please sign in to comment.