stagex/packages/python/Containerfile

54 lines
1.3 KiB
Text
Raw Normal View History

2024-02-09 07:30:28 +00:00
FROM scratch as base
2024-03-28 00:38:03 +00:00
ENV VERSION=3.11.8
ENV SRC_HASH=9e06008c8901924395bc1da303eac567a729ae012baa182ab39269f650383bb3
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-03-28 00:38:03 +00:00
COPY --from=stagex/sqlite3 . /
COPY --from=stagex/libffi . /
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/. /