diff --git a/.circleci/config.yml b/.circleci/config.yml index 5a10bb3..09d90cf 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -13,14 +13,11 @@ jobs: keys: - pkg-cache - run: - name: Build using vendor directory - command: go build -mod=vendor ./cmd/geras - - run: - name: Build using go modules - command: go build ./... + name: Build geras binary + command: go build ./cmd/geras - run: name: Run unit tests - command: go test ./pkg/... + command: go test ./... - run: name: Check flags are documented command: test/flags-doc.sh diff --git a/Dockerfile b/Dockerfile index 349775e..b856e03 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,21 @@ # build stage -FROM golang:alpine AS build-env +FROM golang:1-alpine AS build-env ADD . /src WORKDIR /src RUN apk add git ARG GRPC_HEALTH_PROBE_VERSION=v0.3.0 RUN go get github.com/grpc-ecosystem/grpc-health-probe@${GRPC_HEALTH_PROBE_VERSION} -# Normally built on CircleCI, you can get a dev image with version info with: -# docker build --build-arg GIT_REVISION="$(git rev-parse HEAD)" \ -# --build-arg GIT_BRANCH="$(git rev-parse --abbrev-ref HEAD)" . ARG GERAS_VERSION="development" ARG BUILD_USER="docker" ARG GIT_REVISION="unknown" ARG GIT_BRANCH="unknown" -ENV GO111MODULE=on -RUN go install -mod=vendor -ldflags '-extldflags "-static" \ +RUN if [[ "${GIT_REVISION}" = "unknown" ]]; then \ + GIT_REVISION="$(git rev-parse HEAD)"; \ + GIT_BRANCH="$(git rev-parse --abbrev-ref HEAD)"; \ +fi; \ +go install -ldflags ' \ -X github.com/prometheus/common/version.Version='"${GERAS_VERSION}"' \ -X github.com/prometheus/common/version.Revision='"${GIT_REVISION}"' \ -X github.com/prometheus/common/version.Branch='"${GIT_BRANCH}"' \