11# Stage 1: Build stage environment using alpine python Image
2- FROM python :3.14-alpine3. 22 AS build-env
2+ FROM alpine :3.22 AS build-env
33
44# Set build directory
55WORKDIR /build
66
77# Copy application files
88COPY . .
99
10- # Install python dependencies into a target directory
10+ # Build Python 3.15.0a6 and apk dependencies from source
1111RUN set -e; \
1212 apk add --no-cache \
1313 build-base=0.5-r3 \
1414 cmake=3.31.7-r1 \
1515 coreutils=9.7-r1 \
16- libffi-dev=3.4.8-r0; \
17- pip install --no-cache-dir --upgrade 'pip==26.0' ; \
18- pip install --no-cache-dir -r requirements.txt --target /packages;
16+ libffi-dev=3.4.8-r0 \
17+ openssl-dev=3.5.5-r0 \
18+ zlib-dev=1.3.1-r2 \
19+ bzip2-dev=1.0.8-r6 \
20+ xz-dev=5.8.1-r0 \
21+ wget=1.25.0-r1; \
22+ wget --progress=dot:giga https://www.python.org/ftp/python/3.15.0/Python-3.15.0a6.tgz; \
23+ tar -xzf Python-3.15.0a6.tgz; \
24+ ./Python-3.15.0a6/configure --prefix=/usr/local --enable-shared --with-ensurepip=install; \
25+ make -j"$(nproc)" ; \
26+ make install; \
27+ ln -s /usr/local/bin/python3.15 /usr/local/bin/python;
28+
29+ # Install python dependencies into a target directory
30+ RUN set -e; \
31+ pip3.15 install --no-cache-dir --upgrade 'pip==26.0' ; \
32+ PYO3_USE_ABI3_FORWARD_COMPATIBILITY=1 pip3.15 install --no-cache-dir -r requirements.txt --target /packages;
1933
2034
2135# Stage 2: Runtime Stage using scratch Image
@@ -24,12 +38,13 @@ FROM scratch
2438# Copy necessary system libraries and interpreter from build-env
2539COPY --from=build-env /lib/ld-musl-x86_64.so.1 /lib/ld-musl-x86_64.so.1
2640COPY --from=build-env /lib/libc.musl-x86_64.so.1 /lib/libc.musl-x86_64.so.1
27- COPY --from=build-env /usr/local/lib/libpython3.14 .so.1.0 /usr/local/lib/libpython3.14 .so.1.0
28- COPY --from=build-env /usr/local/lib/python3.14 /usr/local/lib/python3.14
41+ COPY --from=build-env /usr/local/lib/libpython3.15 .so.1.0 /usr/local/lib/libpython3.15 .so.1.0
42+ COPY --from=build-env /usr/local/lib/python3.15 /usr/local/lib/python3.15
2943COPY --from=build-env /usr/lib/libssl.so.3 /usr/lib/libssl.so.3
3044COPY --from=build-env /usr/lib/libcrypto.so.3 /usr/lib/libcrypto.so.3
3145COPY --from=build-env /usr/lib/libz.so.1 /usr/lib/libz.so.1
3246COPY --from=build-env /usr/lib/libgcc_s.so.1 /usr/lib/libgcc_s.so.1
47+ COPY --from=build-env /usr/lib/libffi.so.8 /usr/lib/libffi.so.8
3348
3449# Copy Python installation
3550COPY --from=build-env /usr/local/bin/python /usr/local/bin/python
0 commit comments