go built from only locally built dependency images

This commit is contained in:
Lance Vick 2023-11-13 20:56:30 -08:00
parent 09df9d6868
commit 2b2ec9f7f7
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
3 changed files with 56 additions and 38 deletions

View File

@ -8,7 +8,7 @@ out/musl.oci.tgz: \
docker build -t ocirep/musl --output type=oci,dest=$@ packages/musl
out/busybox.oci.tgz: \
out/bootstrap.oci.tgz \
out/bootstrap.oci.tgz
docker build -t ocirep/busybox --output type=oci,dest=$@ packages/busybox
out/binutils.oci.tgz: \
@ -16,17 +16,22 @@ out/binutils.oci.tgz: \
out/musl.oci.tgz
docker build -t ocirep/musl --output type=oci,dest=$@ packages/musl
out/linux-headers.oci.tgz: \
docker build -t ocirep/linux-headers --output type=oci,dest=$@ packages/linux-heades
out/gcc.oci.tgz: \
out/bootstrap.oci.tgz \
out/musl.oci.tgz
docker build -t ocirep/gcc --output type=oci,dest=$@ packages/gcc
out/bash.oci.tgz: \
out/gcc.oci.tgz \
out/gcc.oci.tgz
docker build -t ocirep/bash --output type=oci,dest=$@ packages/bash
out/go.oci.tgz: \
out/gcc.oci.tgz \
out/binutils.oci.tgz \
out/busybox.oci.tgz \
out/bash.oci.tgz
out/bash.oci.tgz \
out/musl.oci.tgz
docker build -t ocirep/go --output type=oci,dest=$@ packages/go

View File

@ -56,9 +56,9 @@ RUN ["/busybox","mkdir","/bin"]
RUN ["/busybox","--install","-s","/bin"]
RUN echo "user:x:1000:" > /etc/group
RUN echo "user:x:1000:1000::/home/user:/bin/sh" > /etc/passwd
RUN mkdir -p /home/user /tmp /lib
RUN mkdir -p /home/user /tmp /lib /var/tmp
RUN ln -sT /lib /lib64
RUN chown -R 1000:1000 /home/user /tmp
RUN chown -R 1000:1000 /home/user /tmp /var/tmp
WORKDIR /home/user
USER 1000:1000
ENTRYPOINT ["/bin/sh"]

View File

@ -1,74 +1,87 @@
FROM ocirep/busybox:latest as busybox
FROM ocirep/bash:latest as bash
FROM ocirep/glibc:latest as glibc
FROM library/gcc@sha256:ca38f292fe1ad0933f0122a657f9c644ed1f0a9e1aa336abcc83d420ad487e28 as gcc
FROM ocirep/gcc:latest as gcc
FROM ocirep/binutils:latest as binutils
FROM ocirep/musl:latest as musl
FROM gcc as stage1
FROM busybox as stage1
COPY --from=bash . /bin/
COPY --from=gcc . /
COPY --from=binutils . /
COPY --from=musl . /
ENV GO_SITE=https://dl.google.com/go
ENV GO_VERSION=1.4-bootstrap-20171003
ENV GO_HASH=f4ff5b5eb3a3cae1c993723f3eab519c5bae18866b5e5f96fe1102f0cb5c3e52
ENV GOOS=linux
ENV GOROOT_FINAL="/home/user/go-stage1"
ENV GOROOT="${GOROOT_FINAL}"
ENV GOBIN="${GOROOT_FINAL}/bin"
ENV CGO_ENABLED=0
ENV GOROOT_FINAL=/home/user/go-stage1
ENV GOROOT=${GOROOT_FINAL}
ENV GOBIN=${GOROOT_FINAL}/bin
ENV DEST=${GOROOT_FINAL}
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
RUN cd go/src \
&& ./make.bash
RUN cd go \
&& mkdir -p ${GOROOT_FINAL} \
&& cp -R bin lib pkg src ${GOROOT_FINAL}
WORKDIR go
RUN set -eux; \
cd src; \
bash make.bash; \
cd ..; \
mkdir -p ${DEST}; \
cp -R bin lib pkg src ${DEST}
FROM busybox as stage2
COPY --from=stage1 /home/user/go-stage1 go-stage1
COPY --from=bash bash /bin/bash
COPY --from=glibc . /lib
COPY --from=musl . /
COPY --from=bash . /bin/
ENV GO_VERSION=1.19.11
ENV GO_HASH=e25c9ab72d811142b7f41ff6da5165fec2d1be5feec3ef2c66bc0bdecb431489
ENV GOROOT_BOOTSTRAP=/home/user/go-stage1
ENV GO_SITE=https://storage.googleapis.com/golang
ENV GOOS=linux
ENV GOROOT_FINAL=/home/user/go-stage2
ENV GOROOT="${GOROOT_FINAL}"
ENV GOBIN="${GOROOT_FINAL}/bin"
ENV GO11MODULE=off
ENV CGO_ENABLED=0
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}
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
RUN cd go/src \
&& /bin/bash make.bash
RUN cd go \
&& mkdir -p ${GOROOT_FINAL} \
&& cp -R bin lib pkg src ${GOROOT_FINAL}
WORKDIR go
RUN set -eux; \
cd src; \
bash make.bash; \
cd ..; \
mkdir -p ${DEST}; \
cp -R bin lib pkg src ${DEST}
FROM busybox as stage3
COPY --from=stage2 /home/user/go-stage2 go-stage2
COPY --from=bash bash /bin/bash
COPY --from=glibc . /lib
COPY --from=bash . /bin/
ENV GO_VERSION=1.21.4
ENV GO_HASH=47b26a83d2b65a3c1c1bcace273b69bee49a7a7b5168a7604ded3d26a37bd787
ENV GOROOT_BOOTSTRAP=/home/user/go-stage2
ENV GO_SITE=https://storage.googleapis.com/golang
ENV GOOS=linux
ENV GOPROXY=off
ENV GOTOOLCHAIN=local
ENV GOFLAGS=-mod=vendor
ENV GOROOT_FINAL="/lib/go"
ENV GOROOT=/home/user/go-stage2
ENV GOBIN="${GOROOT_FINAL}/bin"
ENV GO11MODULE=on
ENV CGO_ENABLED=0
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
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
RUN cd go/src \
&& /bin/bash make.bash
RUN cd go \
&& mkdir -p ../go-stage3 \
&& cp -R bin lib pkg src ../go-stage3
WORKDIR go
RUN set -eux; \
cd src; \
bash make.bash; \
cd ..; \
mkdir -p ${DEST}; \
cp -R bin lib pkg src ${DEST}
FROM scratch
COPY --from=stage3 /home/user/go-stage3 /