Skip to content

Commit

Permalink
Added build tag to include version info in Docker build (#983)
Browse files Browse the repository at this point in the history
  • Loading branch information
kian99 authored Jul 4, 2023
1 parent b8373d8 commit 1700cee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ COPY . .
RUN echo "${GIT_COMMIT}" | tee ./version/commit.txt
RUN echo "${VERSION}" | tee ./version/version.txt
RUN --mount=type=ssh source /root/.gvm/scripts/gvm && go mod vendor
RUN --mount=type=ssh source /root/.gvm/scripts/gvm && go build -o jimmsrv -race -v -a -mod vendor ./cmd/jimmsrv
RUN --mount=type=ssh source /root/.gvm/scripts/gvm && go build -tags version -o jimmsrv -v -a -mod vendor ./cmd/jimmsrv

# Define a smaller single process image for deployment
FROM ${DOCKER_REGISTRY}ubuntu:20.04 AS deploy-env
Expand Down
5 changes: 5 additions & 0 deletions cmd/jimmsrv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"go.uber.org/zap"

"github.com/CanonicalLtd/jimm"
"github.com/CanonicalLtd/jimm/version"
)

func main() {
Expand All @@ -32,6 +33,10 @@ func main() {

// start initialises the jimmsrv service.
func start(ctx context.Context, s *service.Service) error {
zapctx.Info(ctx, "jimm info",
zap.String("version", version.VersionInfo.Version),
zap.String("commit", version.VersionInfo.GitCommit),
)
if logLevel := os.Getenv("JIMM_LOG_LEVEL"); logLevel != "" {
if err := zapctx.LogLevel.UnmarshalText([]byte(logLevel)); err != nil {
zapctx.Error(ctx, "cannot set log level", zap.Error(err))
Expand Down

0 comments on commit 1700cee

Please sign in to comment.