stagex/packages/python/Containerfile

52 lines
1.2 KiB
Text
Raw Normal View History

2024-02-09 07:30:28 +00:00
FROM scratch as base
ENV VERSION=3.12.0
2023-11-17 10:00:36 +00:00
ENV SRC_HASH=795c34f44df45a0e9b9710c8c71c15c671871524cd412ca14def212e8ccb155d
2024-02-09 07:30:28 +00:00
ENV SRC_FILE=Python-${VERSION}.tar.xz
2024-02-10 11:00:58 +00:00
ENV SRC_SITE=https://www.python.org/ftp/python/${VERSION}/${SRC_FILE}
2023-12-16 23:50:40 +00:00
FROM base as fetch
2024-02-10 10:57:34 +00:00
ADD --checksum=sha256:${SRC_HASH} ${SRC_SITE} .
2023-12-16 23:50:40 +00:00
FROM fetch as build
COPY --from=stagex/busybox . /
COPY --from=stagex/gcc . /
COPY --from=stagex/binutils . /
COPY --from=stagex/make . /
COPY --from=stagex/musl . /
COPY --from=stagex/openssl . /
COPY --from=stagex/zlib . /
2024-03-09 12:35:31 +00:00
COPY --from=stagex/bzip2 . /
2024-02-09 07:30:28 +00:00
RUN tar -xf ${SRC_FILE}
WORKDIR Python-${VERSION}
2024-02-10 21:44:39 +00:00
ENV SOURCE_DATE_EPOCH=1
ENV PYTHONHASHSEED=0
ENV PYTHONDONTWRITEBYTECODE=1
2024-02-09 07:30:28 +00:00
RUN --network=none <<-EOF
set -eux
./configure \
--prefix=/usr \
2023-11-17 10:00:36 +00:00
--enable-shared \
--with-computed-gotos \
2024-02-09 07:30:28 +00:00
--without-ensurepip
make -j "$(nproc)"
2024-02-09 07:30:28 +00:00
EOF
2023-12-16 23:50:40 +00:00
FROM build as install
2024-02-09 07:30:28 +00:00
RUN --network=none <<-EOF
set -eux
make DESTDIR=/rootfs install
ln -s /usr/bin/python3 /rootfs/usr/bin/python
EOF
RUN find /rootfs -exec touch -hcd "@0" "{}" +
2024-02-09 07:30:28 +00:00
FROM scratch as test
COPY --from=install /rootfs/. /
COPY --from=stagex/musl . /
2024-02-09 07:30:28 +00:00
COPY <<-EOF test.py
print("Success")
EOF
RUN python test.py | grep "Success"
2023-11-17 10:00:36 +00:00
FROM stagex/filesystem as package
COPY --from=install /rootfs/. /