-
Notifications
You must be signed in to change notification settings - Fork 3
/
Dockerfile.1.23.4
47 lines (43 loc) · 1.43 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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
# Install some extra tools
RUN mkdir /tmp/tools \
&& : "Install goreleaser" \
&& cd /tmp/tools \
&& git clone https://github.com/goreleaser/goreleaser \
&& cd goreleaser \
&& go build -o /go/bin/goreleaser -v \
&& : "Install golangci-lint" \
&& cd /tmp/tools \
&& git clone https://github.com/golangci/golangci-lint -b v1.62.2 \
&& cd golangci-lint \
&& go build -o /go/bin/golangci-lint -v ./cmd/golangci-lint \
&& : "Clean up the layer" \
&& cd / \
&& rm -rf /tmp/tools \
&& rm -rf /tmp/.cache \
&& rm -rf /go/pkg
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:-}"