Source
FROM scratch AS build
ARG VERSION
COPY --from=stagex/bootstrap-stage3 . /
ADD fetch/go${VERSION}.src.tar.gz .
WORKDIR /go
ENV GOROOT_BOOTSTRAP=/usr/lib/go
RUN --network=none <<-EOF
set -eux
cd src
sh make.bash
cd ..
mkdir -p /rootfs/usr/lib/go
cp -a bin lib pkg src /rootfs/usr/lib/go
mkdir -p /rootfs/usr/bin
ln -s /usr/lib/go/bin/go /rootfs/usr/bin/go
ln -s /usr/lib/go/bin/gofmt /rootfs/usr/bin/gofmt
EOF
ARG TARGETARCH
ADD fetch/go${VERSION}.linux-${TARGETARCH}.tar.gz /tmp/go-binaries
RUN --network=none <<-EOF
set -eux
cd /tmp/go-binaries/go
find bin pkg/tool -type f -exec sha512sum {} + > /tmp/go-sums
cd /rootfs/usr/lib/go
# Verify all binaries from the official build are found and match
sha512sum -c /tmp/go-sums
EOF
FROM stagex/core-filesystem AS package
COPY --from=build /rootfs/ /