FROM scratch as base ENV VERSION=1.29 ENV SRC_HASH=d1f1c9c44c425809718edab34c884c4dd9fd6c18396d779d5bd444da2d420792 ENV SRC_FILE=release-${VERSION}.tar.gz ENV SRC_SITE=https://github.com/kubernetes/kubernetes/archive/refs/heads/${SRC_FILE} ENV GOPATH=/cache/go ENV GOCACHE=/cache/ ENV GOWORK=off ENV GOPROXY=https://proxy.golang.org,direct ENV GOSUMDB=sum.golang.org ENV CGO_ENABLED=0 ENV GOHOSTOS=linux ENV GOHOSTARCH=amd64 FROM base as fetch COPY --from=stagex/busybox . / COPY --from=stagex/go . / COPY --from=stagex/ca-certificates . / ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE} . RUN tar -xvf ${SRC_FILE} WORKDIR kubernetes-release-${VERSION} RUN go get ./... FROM fetch as build RUN --network=none go build -trimpath -v k8s.io/kubernetes/cmd/kubectl from build as install RUN <<-EOF mkdir -p /rootfs/usr/bin/ cp kubectl /rootfs/usr/bin/ find /rootfs -exec touch -hcd "@0" "{}" + EOF FROM stagex/filesystem as package COPY --from=install /rootfs/./ /