forked from brimstone/docker-golang
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Dockerfile.1.23.4
29 lines (26 loc) · 946 Bytes
/
Dockerfile.1.23.4
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.23.4 \
&& DIGEST='6924efde5de86fe277676e929dc9917d466efa02fb934197bc2eba35d5680971' \
&& 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:-}"