2023-12-10 18:05:50 +00:00
|
|
|
ARG REGISTRY = local
|
2023-11-17 10:00:25 +00:00
|
|
|
ARG BUSYBOX_VERSION = latest
|
2023-12-10 18:05:50 +00:00
|
|
|
FROM ${REGISTRY}/busybox:${BUSYBOX_VERSION} as busybox
|
|
|
|
FROM ${REGISTRY}/bash:latest as bash
|
|
|
|
FROM ${REGISTRY}/gcc:latest as gcc
|
|
|
|
FROM ${REGISTRY}/binutils:latest as binutils
|
|
|
|
FROM ${REGISTRY}/musl:latest as musl
|
2023-11-02 12:12:38 +00:00
|
|
|
|
2023-11-14 04:56:30 +00:00
|
|
|
FROM busybox as stage1
|
|
|
|
COPY --from=bash . /bin/
|
|
|
|
COPY --from=gcc . /
|
|
|
|
COPY --from=binutils . /
|
|
|
|
COPY --from=musl . /
|
2023-11-09 10:12:11 +00:00
|
|
|
ENV GO_SITE=https://dl.google.com/go
|
|
|
|
ENV GO_VERSION=1.4-bootstrap-20171003
|
|
|
|
ENV GO_HASH=f4ff5b5eb3a3cae1c993723f3eab519c5bae18866b5e5f96fe1102f0cb5c3e52
|
2023-11-02 12:12:38 +00:00
|
|
|
ENV GOOS=linux
|
|
|
|
ENV CGO_ENABLED=0
|
2023-11-14 04:56:30 +00:00
|
|
|
ENV GOROOT_FINAL=/home/user/go-stage1
|
|
|
|
ENV GOROOT=${GOROOT_FINAL}
|
|
|
|
ENV GOBIN=${GOROOT_FINAL}/bin
|
|
|
|
ENV DEST=${GOROOT_FINAL}
|
2023-11-09 10:12:11 +00:00
|
|
|
RUN wget ${GO_SITE}/go${GO_VERSION}.tar.gz
|
|
|
|
RUN echo "${GO_HASH} go${GO_VERSION}.tar.gz" | sha256sum -c
|
|
|
|
RUN tar -xzf go${GO_VERSION}.tar.gz
|
2023-11-14 04:56:30 +00:00
|
|
|
WORKDIR go
|
|
|
|
RUN set -eux; \
|
|
|
|
cd src; \
|
|
|
|
bash make.bash; \
|
|
|
|
cd ..; \
|
|
|
|
mkdir -p ${DEST}; \
|
|
|
|
cp -R bin lib pkg src ${DEST}
|
2023-11-02 12:12:38 +00:00
|
|
|
|
2023-11-09 10:12:11 +00:00
|
|
|
FROM busybox as stage2
|
2023-11-09 12:14:02 +00:00
|
|
|
COPY --from=stage1 /home/user/go-stage1 go-stage1
|
2023-11-14 04:56:30 +00:00
|
|
|
COPY --from=musl . /
|
|
|
|
COPY --from=bash . /bin/
|
2023-11-09 10:12:11 +00:00
|
|
|
ENV GO_VERSION=1.19.11
|
|
|
|
ENV GO_HASH=e25c9ab72d811142b7f41ff6da5165fec2d1be5feec3ef2c66bc0bdecb431489
|
|
|
|
ENV GO_SITE=https://storage.googleapis.com/golang
|
2023-11-02 12:12:38 +00:00
|
|
|
ENV GOOS=linux
|
|
|
|
ENV GO11MODULE=off
|
|
|
|
ENV CGO_ENABLED=0
|
2023-11-14 04:56:30 +00:00
|
|
|
ENV GOROOT_BOOTSTRAP=/home/user/go-stage1
|
|
|
|
ENV GOROOT_FINAL=/home/user/go-stage2
|
|
|
|
ENV GOROOT=${GOROOT_FINAL}
|
|
|
|
ENV GOBIN=${GOROOT_FINAL}/bin
|
|
|
|
ENV DEST=${GOROOT_FINAL}
|
2023-11-09 10:12:11 +00:00
|
|
|
RUN wget ${GO_SITE}/go${GO_VERSION}.src.tar.gz
|
|
|
|
RUN echo "${GO_HASH} go${GO_VERSION}.src.tar.gz" | sha256sum -c
|
|
|
|
RUN tar -xvzf go${GO_VERSION}.src.tar.gz
|
2023-11-14 04:56:30 +00:00
|
|
|
WORKDIR go
|
|
|
|
RUN set -eux; \
|
|
|
|
cd src; \
|
|
|
|
bash make.bash; \
|
|
|
|
cd ..; \
|
|
|
|
mkdir -p ${DEST}; \
|
|
|
|
cp -R bin lib pkg src ${DEST}
|
2023-11-09 10:12:11 +00:00
|
|
|
|
|
|
|
FROM busybox as stage3
|
2023-11-09 12:14:02 +00:00
|
|
|
COPY --from=stage2 /home/user/go-stage2 go-stage2
|
2023-11-14 04:56:30 +00:00
|
|
|
COPY --from=bash . /bin/
|
2023-11-09 10:12:11 +00:00
|
|
|
ENV GO_VERSION=1.21.4
|
|
|
|
ENV GO_HASH=47b26a83d2b65a3c1c1bcace273b69bee49a7a7b5168a7604ded3d26a37bd787
|
|
|
|
ENV GO_SITE=https://storage.googleapis.com/golang
|
2023-11-02 12:12:38 +00:00
|
|
|
ENV GOOS=linux
|
|
|
|
ENV GOPROXY=off
|
|
|
|
ENV GOTOOLCHAIN=local
|
|
|
|
ENV GOFLAGS=-mod=vendor
|
|
|
|
ENV GO11MODULE=on
|
|
|
|
ENV CGO_ENABLED=0
|
2023-11-14 04:56:30 +00:00
|
|
|
ENV GOROOT_BOOTSTRAP=/home/user/go-stage2
|
|
|
|
ENV GOROOT_FINAL="/lib/go"
|
|
|
|
ENV GOROOT=/home/user/go-stage2
|
|
|
|
ENV GOBIN=${GOROOT_FINAL}/bin
|
|
|
|
ENV DEST=/home/user/go-stage3
|
2023-11-09 10:12:11 +00:00
|
|
|
RUN wget ${GO_SITE}/go${GO_VERSION}.src.tar.gz
|
|
|
|
RUN echo "${GO_HASH} go${GO_VERSION}.src.tar.gz" | sha256sum -c
|
|
|
|
RUN tar -xvzf go${GO_VERSION}.src.tar.gz
|
2023-11-14 04:56:30 +00:00
|
|
|
WORKDIR go
|
|
|
|
RUN set -eux; \
|
|
|
|
cd src; \
|
|
|
|
bash make.bash; \
|
|
|
|
cd ..; \
|
|
|
|
mkdir -p ${DEST}; \
|
|
|
|
cp -R bin lib pkg src ${DEST}
|
2023-11-02 12:12:38 +00:00
|
|
|
|
|
|
|
FROM scratch
|
2023-11-09 12:14:02 +00:00
|
|
|
COPY --from=stage3 /home/user/go-stage3 /
|
2023-11-09 10:12:11 +00:00
|
|
|
USER 100:100
|
|
|
|
ENTRYPOINT ["/bin/go"]
|
|
|
|
CMD ["version"]
|