diff --git a/Dockerfile b/Dockerfile index e06663d..f61c97e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,11 @@ # 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 . +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 diff --git a/main.go b/main.go index 05a8a15..168dff6 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,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", }, @@ -139,6 +139,8 @@ func main() { default: log.Fatalf("Invalid log format '%s', please use on of [text, json, gelf]", c.String("log-format")) } + + log.Infof("Starting ReSeC %s", Version) return nil } app.Action = func(c *cli.Context) error {