forked from brimstone/docker-golang
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.1.20.14
29 lines (26 loc) · 947 Bytes
/
Dockerfile.1.20.14
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
ARG IMAGE_NAME
FROM ${IMAGE_NAME}:temp as image
RUN GOLANG_VERSION=1.20.14 \
&& DIGEST='ff445e48af27f93f66bd949ae060d97991c83e11289009d311f25426258f9c44' \
&& wget -O go.tgz "https://golang.org/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz" \
&& echo "${DIGEST} *go.tgz" | sha256sum -c - \
&& tar -C /usr/local -xzf go.tgz \
&& rm go.tgz \
&& echo PATH: $PATH \
&& go version
FROM image as onbuild
ONBUILD ARG GOARCH
ONBUILD ENV GOARCH=$GOARCH
ONBUILD ARG REPOSITORY
ONBUILD WORKDIR /go/src/${REPOSITORY}/
ONBUILD ARG CGO_ENABLED
ONBUILD ENV CGO_ENABLED=${CGO_ENABLED} \
GO111MODULE=on
ONBUILD COPY go.mod .
ONBUILD COPY go.sum .
ONBUILD RUN go mod download
ONBUILD RUN go list -f '{{if (and ( not .Main) (not .Indirect))}}{{.Path}}@{{.Version}}{{end}}' -m all | xargs -tn 1 go get -v || true
ONBUILD COPY . .
ONBUILD ARG PACKAGE
ONBUILD ENV PACKAGE=${PACKAGE}
ONBUILD RUN /loader go build -v -o /app "${PACKAGE:-}"