2024-02-09 07:30:28 +00:00
|
|
|
FROM scratch as base
|
2024-04-09 02:52:48 +00:00
|
|
|
ENV VERSION=1.22.2
|
|
|
|
ENV SRC_HASH=374ea82b289ec738e968267cac59c7d5ff180f9492250254784b2044e90df5a9
|
2024-02-09 07:30:28 +00:00
|
|
|
ENV SRC_FILE=go${VERSION}.src.tar.gz
|
|
|
|
ENV SRC_SITE=https://storage.googleapis.com/golang/${SRC_FILE}
|
2024-03-19 04:46:04 +00:00
|
|
|
ENV VERSION_BOOTSTRAP_3=1.20.6
|
|
|
|
ENV SRC_HASH_BOOTSTRAP_3=62ee5bc6fb55b8bae8f705e0cb8df86d6453626b4ecf93279e2867092e0b7f70
|
|
|
|
ENV SRC_FILE_BOOTSTRAP_3=go${VERSION_BOOTSTRAP_3}.src.tar.gz
|
|
|
|
ENV SRC_SITE_BOOTSTRAP_3=https://storage.googleapis.com/golang/${SRC_FILE_BOOTSTRAP_3}
|
2023-12-16 23:50:40 +00:00
|
|
|
ENV VERSION_BOOTSTRAP_2=1.19.11
|
|
|
|
ENV SRC_HASH_BOOTSTRAP_2=e25c9ab72d811142b7f41ff6da5165fec2d1be5feec3ef2c66bc0bdecb431489
|
2024-02-09 07:30:28 +00:00
|
|
|
ENV SRC_FILE_BOOTSTRAP_2=go${VERSION_BOOTSTRAP_2}.src.tar.gz
|
|
|
|
ENV SRC_SITE_BOOTSTRAP_2=https://storage.googleapis.com/golang/${SRC_FILE_BOOTSTRAP_2}
|
2023-12-16 23:50:40 +00:00
|
|
|
ENV VERSION_BOOTSTRAP_1=1.4-bootstrap-20171003
|
|
|
|
ENV SRC_HASH_BOOTSTRAP_1=f4ff5b5eb3a3cae1c993723f3eab519c5bae18866b5e5f96fe1102f0cb5c3e52
|
2024-02-09 07:30:28 +00:00
|
|
|
ENV SRC_FILE_BOOTSTRAP_1=go${VERSION_BOOTSTRAP_1}.tar.gz
|
|
|
|
ENV SRC_SITE_BOOTSTRAP_1=https://dl.google.com/go/${SRC_FILE_BOOTSTRAP_1}
|
2023-12-14 16:27:58 +00:00
|
|
|
|
2023-12-16 23:50:40 +00:00
|
|
|
FROM base as fetch
|
2024-02-11 00:02:15 +00:00
|
|
|
ADD --checksum=sha256:${SRC_HASH_BOOTSTRAP_1} ${SRC_SITE_BOOTSTRAP_1} .
|
|
|
|
ADD --checksum=sha256:${SRC_HASH_BOOTSTRAP_2} ${SRC_SITE_BOOTSTRAP_2} .
|
2024-03-19 04:46:04 +00:00
|
|
|
ADD --checksum=sha256:${SRC_HASH_BOOTSTRAP_3} ${SRC_SITE_BOOTSTRAP_3} .
|
2024-02-11 00:02:15 +00:00
|
|
|
ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE} .
|
2023-12-16 23:50:40 +00:00
|
|
|
|
|
|
|
FROM fetch as build
|
2024-02-15 15:22:38 +00:00
|
|
|
COPY --from=stagex/busybox . /
|
|
|
|
COPY --from=stagex/gcc . /
|
|
|
|
COPY --from=stagex/bash . /
|
|
|
|
COPY --from=stagex/musl . /
|
|
|
|
COPY --from=stagex/binutils . /
|
2024-02-09 07:30:28 +00:00
|
|
|
RUN <<-EOF
|
|
|
|
set -eux
|
|
|
|
tar -xzf go${VERSION_BOOTSTRAP_1}.tar.gz
|
|
|
|
mv go go-bootstrap-1-src
|
|
|
|
tar -xzf go${VERSION_BOOTSTRAP_2}.src.tar.gz
|
|
|
|
mv go go-bootstrap-2-src
|
2024-03-19 04:46:04 +00:00
|
|
|
tar -xzf go${VERSION_BOOTSTRAP_3}.src.tar.gz
|
|
|
|
mv go go-bootstrap-3-src
|
2024-02-09 07:30:28 +00:00
|
|
|
tar -xzf go${VERSION}.src.tar.gz; \
|
|
|
|
mv go go-src
|
|
|
|
EOF
|
|
|
|
WORKDIR go-bootstrap-1-src
|
|
|
|
ENV GOOS=linux
|
|
|
|
ENV CGO_ENABLED=0
|
|
|
|
ENV GOROOT_FINAL=/go-bootstrap-1
|
2023-11-14 04:56:30 +00:00
|
|
|
ENV GOROOT=${GOROOT_FINAL}
|
|
|
|
ENV DEST=${GOROOT_FINAL}
|
2023-12-14 16:27:58 +00:00
|
|
|
ENV GOBIN=${GOROOT_FINAL}/bin
|
2024-02-09 07:30:28 +00:00
|
|
|
RUN --network=none <<-EOF
|
|
|
|
set -eux
|
|
|
|
cd src
|
|
|
|
bash make.bash
|
|
|
|
cd ..
|
|
|
|
mkdir -p ${DEST}
|
|
|
|
cp -R bin lib pkg src ${DEST}
|
|
|
|
EOF
|
|
|
|
WORKDIR ../go-bootstrap-2-src
|
2023-11-02 12:12:38 +00:00
|
|
|
ENV GO11MODULE=off
|
2024-02-09 07:30:28 +00:00
|
|
|
ENV GOROOT_BOOTSTRAP=/go-bootstrap-1
|
|
|
|
ENV GOROOT_FINAL=/go-bootstrap-2
|
2023-11-14 04:56:30 +00:00
|
|
|
ENV GOROOT=${GOROOT_FINAL}
|
|
|
|
ENV DEST=${GOROOT_FINAL}
|
2023-12-14 16:27:58 +00:00
|
|
|
ENV GOBIN=${GOROOT_FINAL}/bin
|
2024-02-09 07:30:28 +00:00
|
|
|
RUN --network=none <<-EOF
|
|
|
|
set -eux
|
|
|
|
cd src
|
|
|
|
bash make.bash
|
|
|
|
cd ..
|
|
|
|
mkdir -p ${DEST}
|
|
|
|
cp -R bin lib pkg src ${DEST}
|
|
|
|
EOF
|
2024-03-19 04:46:04 +00:00
|
|
|
WORKDIR ../go-bootstrap-3-src
|
|
|
|
ENV GO11MODULE=off
|
|
|
|
ENV GOROOT_BOOTSTRAP=/go-bootstrap-2
|
|
|
|
ENV GOROOT_FINAL=/go-bootstrap-3
|
|
|
|
ENV GOROOT=${GOROOT_FINAL}
|
|
|
|
ENV DEST=${GOROOT_FINAL}
|
|
|
|
ENV GOBIN=${GOROOT_FINAL}/bin
|
|
|
|
RUN --network=none <<-EOF
|
|
|
|
set -eux
|
|
|
|
cd src
|
|
|
|
bash make.bash
|
|
|
|
cd ..
|
|
|
|
mkdir -p ${DEST}
|
|
|
|
cp -R bin lib pkg src ${DEST}
|
|
|
|
EOF
|
2024-02-09 07:30:28 +00:00
|
|
|
WORKDIR ../go-src
|
2023-11-02 12:12:38 +00:00
|
|
|
ENV GOPROXY=off
|
|
|
|
ENV GOTOOLCHAIN=local
|
|
|
|
ENV GOFLAGS=-mod=vendor
|
|
|
|
ENV GO11MODULE=on
|
2024-03-19 04:46:04 +00:00
|
|
|
ENV GOROOT_BOOTSTRAP=/go-bootstrap-3
|
2023-11-14 04:56:30 +00:00
|
|
|
ENV GOROOT_FINAL="/lib/go"
|
|
|
|
ENV GOBIN=${GOROOT_FINAL}/bin
|
2024-03-19 04:46:04 +00:00
|
|
|
ENV GOROOT=/go-bootstrap-3
|
2024-02-09 07:30:28 +00:00
|
|
|
RUN --network=none <<-EOF
|
|
|
|
set -eux
|
|
|
|
cd src
|
|
|
|
bash make.bash
|
|
|
|
EOF
|
2023-12-16 23:50:40 +00:00
|
|
|
|
|
|
|
FROM build as install
|
2024-02-09 07:30:28 +00:00
|
|
|
RUN <<-EOF
|
|
|
|
set -eux
|
2024-03-01 18:30:23 +00:00
|
|
|
mkdir -p /rootfs/usr
|
|
|
|
cp -R pkg src /rootfs
|
|
|
|
cp -R bin lib /rootfs/usr
|
2024-02-09 07:30:28 +00:00
|
|
|
EOF
|
2024-02-09 18:19:36 +00:00
|
|
|
RUN find /rootfs -exec touch -hcd "@0" "{}" +
|
2023-11-02 12:12:38 +00:00
|
|
|
|
2023-12-14 16:27:58 +00:00
|
|
|
FROM base as test
|
2024-03-01 18:30:23 +00:00
|
|
|
COPY --from=install /rootfs/. /
|
2024-02-09 07:30:28 +00:00
|
|
|
COPY <<-EOF test.go
|
|
|
|
package main
|
|
|
|
import "fmt"
|
|
|
|
func main() { fmt.Println("Success") }
|
|
|
|
EOF
|
|
|
|
RUN <<-EOF
|
|
|
|
set -eux
|
|
|
|
go build test.go
|
|
|
|
./test | grep "Success"
|
|
|
|
EOF
|
2023-12-14 16:27:58 +00:00
|
|
|
|
2024-03-01 18:30:23 +00:00
|
|
|
FROM stagex/filesystem as package
|
|
|
|
COPY --from=install /rootfs/. /
|