Skip to content

Commit

Permalink
Stop doing vendor build, go modules are good in 1.13
Browse files Browse the repository at this point in the history
Plus misc cleanups in dockerfile:
- Use "1-alpine" to get Go v1 compatibility promise
- Include git revision when built by docker in the source tree
  (i.e. don't require someone to specify it)
  • Loading branch information
dgl committed Nov 1, 2019
1 parent 356e1ad commit 135533b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
9 changes: 3 additions & 6 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -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}"' \
Expand Down

0 comments on commit 135533b

Please sign in to comment.