From 5aa7a79d80b596a945d12f22cd6f7c1f85dedbd1 Mon Sep 17 00:00:00 2001 From: zikaeroh <48577114+zikaeroh@users.noreply.github.com> Date: Tue, 7 Jul 2020 22:54:38 -0700 Subject: [PATCH] Run version command during docker build --- Dockerfile | 3 +++ main.go | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/Dockerfile b/Dockerfile index 55d2f2e..fa88042 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,3 +35,6 @@ FROM gcr.io/distroless/base:nonroot COPY --from=GO_BUILD /codies/codies /codies ENTRYPOINT [ "/codies", "--prod" ] EXPOSE 5000 + +# Verify that the binary works. +RUN [ "/codies", "version" ] diff --git a/main.go b/main.go index 9123d89..ba54054 100644 --- a/main.go +++ b/main.go @@ -39,6 +39,11 @@ var args = struct { var wsOpts *websocket.AcceptOptions func main() { + if argv := os.Args[1:]; len(argv) > 0 && argv[0] == "version" { + fmt.Println(version.Version()) + return + } + rand.Seed(time.Now().Unix()) if _, err := flags.Parse(&args); err != nil {