Files
athens/cmd/proxy/Dockerfile
Rob j Loranger 2f524d27c3 add build details to binary (#866)
* poc

* finish JSON, remove uneeded methods, update docker file, finish script details

* build.Details didn't need to be exported

* typo

* somehow missed this

* should default to false

* Fix some things

remove commit SHA as build script will now create a hybrid for version
as in the push-docker-images.sh script, code shamelessly stolen.

change JSON function to Data and return a struct, the caller can do what
they like with that data, i.e. marshall JSON for a response body.

* add struct tags

* use build script in docker image

* newline in build.sh

* use previously generated version for binary build

* Working docker args

removed script build.sh, was not really needed.

date is generated automatically during docker build process.

VERSION will be set to 'Not Specified', or the version set during
our CI docker build/push step. A user can set their own version during
build using ldflags.

* remove old comment re: script

* Yikes

Almost forgot to remove my testing junk

* GitHub on my phone is hard
2018-11-09 10:32:55 -08:00

32 lines
1.1 KiB
Docker

# Links to compare against to ensure we have all VCS's setup in this build
# https://github.com/docker-library/buildpack-deps/blob/1845b3f918f69b4c97912b0d4d68a5658458e84f/stretch/scm/Dockerfile
# https://github.com/golang/go/blob/f082dbfd4f23b0c95ee1de5c2b091dad2ff6d930/src/cmd/go/internal/get/vcs.go#L90
FROM golang:1.11-alpine AS builder
WORKDIR $GOPATH/src/github.com/gomods/athens
COPY . .
ARG VERSION="Not Specified"
RUN GO111MODULE=on CGO_ENABLED=0 go build -mod=vendor -ldflags "-X github.com/gomods/athens/pkg/build.version=$VERSION -X github.com/gomods/athens/pkg/build.buildDate=$(date -u +%Y-%m-%d-%H:%M:%S-%Z)" -o /bin/athens-proxy ./cmd/proxy
FROM alpine
ENV GO111MODULE=on
COPY --from=builder /bin/athens-proxy /bin/athens-proxy
COPY --from=builder /go/src/github.com/gomods/athens/config.dev.toml /config/config.toml
COPY --from=builder /usr/local/go/bin/go /bin/go
RUN apk update && \
apk add --no-cache bzr git mercurial openssh-client subversion procps fossil && \
mkdir -p /usr/local/go
ENV GO_ENV=production
EXPOSE 3000
CMD ["athens-proxy", "-config_file=/config/config.toml"]