From 228c70521d37ccb9fde3bfe9cc71889599b0188f Mon Sep 17 00:00:00 2001 From: Andrei Burd Date: Tue, 28 Jul 2020 15:26:29 +0300 Subject: [PATCH 1/3] Go 1.14 and version awarness --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e06663d..1e6d344 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ # Build layer -FROM golang:1.13 AS builder +FROM golang:1.14 AS builder WORKDIR /go/src/github.com/seatgeek/resec COPY . . -RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o build/resec . +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-X 'main.Version=${DOCKER_TAG}'" -a -installsuffix cgo -o build/resec . # Run layer FROM alpine:latest From 49fb7dc634d09f35cd9fdaa527467ec284837d5a Mon Sep 17 00:00:00 2001 From: Andrei Burd Date: Tue, 28 Jul 2020 15:56:46 +0300 Subject: [PATCH 2/3] dockerhub hooks --- Dockerfile | 5 ++++- hooks/build | 8 ++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 hooks/build diff --git a/Dockerfile b/Dockerfile index 1e6d344..f61c97e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,10 @@ FROM golang:1.14 AS builder WORKDIR /go/src/github.com/seatgeek/resec COPY . . -RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-X 'main.Version=${DOCKER_TAG}'" -a -installsuffix cgo -o build/resec . +ARG RESEC_VERSION +ENV RESEC_VERSION ${RESEC_VERSION:-local-dev} +RUN echo $RESEC_VERSION +RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-X 'main.Version=${RESEC_VERSION}'" -a -installsuffix cgo -o build/resec . # Run layer FROM alpine:latest diff --git a/hooks/build b/hooks/build new file mode 100644 index 0000000..ea059fc --- /dev/null +++ b/hooks/build @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ $DOCKER_TAG == "latest" ] +then + docker build . --build-arg RESEC_VERSION=${SOURCE_BRANCH} -t ${IMAGE_NAME} +else + docker build . --build-arg RESEC_VERSION=${DOCKER_TAG} -t ${IMAGE_NAME} +fi From 80864a5a70f1d6bebbf9380cce9a8e3008cc863f Mon Sep 17 00:00:00 2001 From: Andrei Burd Date: Tue, 28 Jul 2020 16:11:56 +0300 Subject: [PATCH 3/3] Logging Resec version on Start --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 3e166a6..d58d151 100644 --- a/main.go +++ b/main.go @@ -33,7 +33,7 @@ func main() { }, cli.StringFlag{ Name: "consul-lock-key", - Usage: "KV lock location, should be overriden if multiple instances running in the same consul DC", + Usage: "KV lock location, should be overridden if multiple instances running in the same consul DC", Value: "resec/.lock", EnvVar: "CONSUL_LOCK_KEY", }, @@ -132,6 +132,8 @@ func main() { default: log.Fatal("Invalid log format (text, json, gelf)") } + + log.Infof("Starting ReSeC %s", Version) return nil } app.Action = func(c *cli.Context) error {