FROM scratch as base ENV VERSION=2.9.5 ENV SRC_HASH=a4bea37ecb9a3fb5c0c8ef18c2f7eeaf8ccbcfec91f72f3bccfc6bf72a3e3902 ENV SRC_FILE=git-${VERSION}.tar.xz ENV SRC_SITE=http://mirrors.edge.kernel.org/pub/software/scm/git/${SRC_FILE} FROM base as fetch ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE} . FROM fetch as build COPY --from=stagex/busybox . / COPY --from=stagex/musl . / COPY --from=stagex/gcc . / COPY --from=stagex/curl . / COPY --from=stagex/openssl . / COPY --from=stagex/binutils . / COPY --from=stagex/make . / COPY --from=stagex/zlib . / COPY --from=stagex/perl . / COPY --from=stagex/gettext . / RUN tar -xvf $SRC_FILE WORKDIR git-${VERSION} ENV SOURCE_DATE_EPOCH=1 RUN --network=none <<-EOF set -eux ./configure \ --build=x86_64-unknown-linux-musl \ --host=x86_64-unknown-linux-musl \ --prefix=/usr \ --bindir=/usr/bin \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --disable-nls \ --enable-readline \ --without-curses \ --without-bash-malloc \ --without-tcltk make -j "$(nproc)" EOF FROM build as install RUN make DESTDIR=/rootfs install FROM base as test COPY --from=install /rootfs/. / COPY --from=stagex/zlib . / COPY --from=stagex/musl . / COPY --from=stagex/busybox . / RUN /bin/sh <<-EOF set -eux EXPECTED_GIT_VERSION="git version ${VERSION}" GIT_VERSION=\$(git --version) if [ "\$GIT_VERSION" != "\$EXPECTED_GIT_VERSION" ]; then echo "Expected git version is \$EXPECTED_GIT_VERSION, but got \$GIT_VERSION" exit 1 fi EOF FROM stagex/filesystem as package COPY --from=install /rootfs/. /