stagex/packages/python/Containerfile

51 lines
1.1 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
2024-02-09 07:30:28 +00:00
COPY --from=busybox . /
COPY --from=gcc . /
COPY --from=binutils . /
COPY --from=make . /
COPY --from=musl . /
COPY --from=openssl . /
COPY --from=zlib . /
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
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=musl . /
COPY <<-EOF test.py
print("Success")
EOF
RUN python test.py | grep "Success"
2023-11-17 10:00:36 +00:00
2023-12-12 17:45:39 +00:00
FROM scratch as package
2023-12-16 23:50:40 +00:00
COPY --from=install /rootfs /