Skip to content

Commit 26bb326

Browse files
committedFeb 24, 2025··
fix: use binary instead of source to install go
1 parent 56398ce commit 26bb326

File tree

1 file changed

+10
-42
lines changed

1 file changed

+10
-42
lines changed
 

‎Dockerfile

+10-42
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,19 @@ RUN apt-get update && apt-get install -y --no-install-recommends ca-certificates
44

55
COPY scripts/build ./scripts
66

7-
ENV GOLANG_VERSION 1.23.6
8-
9-
RUN set -eux; \
10-
apt-get install -y --no-install-recommends bash build-essential openssl golang-go curl wget; \
11-
rm -rf /var/lib/apt/lists/*; \
12-
export \
13-
# set GOROOT_BOOTSTRAP such that we can actually build Go
14-
GOROOT_BOOTSTRAP="$(go env GOROOT)" \
15-
# ... and set "cross-building" related vars to the installed system's values so that we create a build targeting the proper arch
16-
# (for example, if our build host is GOARCH=amd64, but our build env/image is GOARCH=386, our build needs GOARCH=386)
17-
GOOS="$(go env GOOS)" \
18-
GOARCH="$(go env GOARCH)" \
19-
GOHOSTOS="$(go env GOHOSTOS)" \
20-
GOHOSTARCH="$(go env GOHOSTARCH)" \
21-
; \
22-
# also explicitly set GO386 and GOARM if appropriate
23-
# https://github.com/docker-library/golang/issues/184
24-
dpkgArch="$(dpkg --print-architecture)"; \
25-
case "$dpkgArch" in \
26-
armhf) export GOARM='6' ;; \
27-
armv7) export GOARM='7' ;; \
28-
x86) export GO386='387' ;; \
29-
esac; \
30-
\
31-
wget -O go.tgz "https://golang.org/dl/go$GOLANG_VERSION.src.tar.gz"; \
32-
tar -C /usr/local -xzf go.tgz; \
33-
rm go.tgz; \
34-
\
35-
cd /usr/local/go/src; \
36-
./make.bash; \
37-
\
38-
rm -rf \
39-
# https://github.com/golang/go/blob/0b30cf534a03618162d3015c8705dd2231e34703/src/cmd/dist/buildtool.go#L121-L125
40-
/usr/local/go/pkg/bootstrap \
41-
# https://golang.org/cl/82095
42-
# https://github.com/golang/build/blob/e3fe1605c30f6a3fd136b561569933312ede8782/cmd/release/releaselet.go#L56
43-
/usr/local/go/pkg/obj \
44-
; \
45-
\
46-
export PATH="/usr/local/go/bin:$PATH"; \
47-
go version
7+
ENV GOLANG_VERSION 1.24.0
8+
9+
RUN set -eux; apt-get install -y --no-install-recommends bash build-essential openssl wget;
10+
11+
12+
RUN wget https://go.dev/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz \
13+
&& rm -rf /usr/local/go && tar -C /usr/local -xzf go1.24.0.linux-amd64.tar.gz \
14+
&& rm go1.24.0.linux-amd64.tar.gz
4815

4916
ENV GOPATH /go
5017
ENV PATH $GOPATH/bin:/usr/local/go/bin:$PATH
51-
ENV GO111MODULE=on
18+
19+
RUN go version
5220

5321
RUN mkdir -p "$GOPATH/src" "$GOPATH/bin" && chmod -R 777 "$GOPATH"
5422

0 commit comments

Comments
 (0)
Please sign in to comment.