docker: clone source from GitHub, check out version

To prepare for creating production docker images and uploading them to
docker hub, we want them to be built from the repository and from a
specified git commit or tag.
This commit is contained in:
Oliver Gugger
2020-12-02 09:50:02 +01:00
parent ad6a69b1b5
commit df0b3e88ce

View File

@@ -1,21 +1,22 @@
FROM golang:1.13-alpine as builder
# Copy in the local repository to build from.
COPY . /go/src/github.com/lightninglabs/aperture
FROM golang:1.15.5-alpine as builder
# Force Go to use the cgo based DNS resolver. This is required to ensure DNS
# queries required to connect to linked containers succeed.
ENV GODEBUG netdns=cgo
# Explicitly turn on the use of modules (until this becomes the default).
ENV GO111MODULE on
# Pass a tag, branch or a commit using build-arg. This allows a docker image to
# be built from a specified Git state. The default image will use the Git tip of
# master by default.
ARG checkout="master"
# Install dependencies and install/build aperture
RUN apk add --no-cache --update alpine-sdk \
git \
make \
&& cd /go/src/github.com/lightninglabs/aperture/cmd \
&& go install ./...
&& git clone https://github.com/lightninglabs/aperture /go/src/github.com/lightninglabs/aperture \
&& cd /go/src/github.com/lightninglabs/aperture \
&& git checkout $checkout \
&& make install
# Start a new, final image to reduce size.
FROM alpine as final