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

Added build tag to include version info in Docker build #983

Merged
merged 1 commit into from
Jul 4, 2023
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
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",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this since it's available via /debug/info endpoint?

Copy link
Contributor Author

@kian99 kian99 Jul 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's nice for seeing in the logs especially when you can't get the server to start due to missing config, at least this way you have a way to see what version of the server is running, will prevent some confusion in the future I'm sure.

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