FROM scratch as base ENV VERSION=2.10.0 ENV SRC_HASH=bdabb6d336998cbb378d4b9db3a4b56a1e3235701dc05ea2690d9a997ed5041c ENV SRC_FILE=semantic_version-${VERSION}.tar.gz ENV SRC_SITE=https://files.pythonhosted.org/packages/source/s/semantic_version/${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/zlib . / COPY --from=stagex/libffi . / COPY --from=stagex/python . / COPY --from=stagex/py-flit . / COPY --from=stagex/py-wheel . / COPY --from=stagex/py-setuptools . / COPY --from=stagex/py-gpep517 . / COPY --from=stagex/py-installer . / RUN tar -xzf ${SRC_FILE} WORKDIR semantic_version-${VERSION} RUN gpep517 build-wheel --wheel-dir .dist --output-fd 3 3>&1 >&2 FROM build as install RUN <<-EOF set -eu python -m installer -d /rootfs .dist/*.whl find /rootfs | grep -E "(/__pycache__$|\.pyc$|\.pyo$)" | xargs rm -rf find /rootfs -exec touch -hcd "@0" "{}" + EOF FROM stagex/filesystem as package COPY --from=install /rootfs/. /