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