|
1 | | - FROM --platform=linux/ppc64le docker.io/ubuntu:24.04 as base |
| 1 | +FROM --platform=linux/ppc64le docker.io/ubuntu:24.04 as base |
2 | 2 |
|
3 | | - # Language variables |
4 | | - ENV LC_ALL=C.UTF-8 |
5 | | - ENV LANG=C.UTF-8 |
6 | | - ENV LANGUAGE=C.UTF-8 |
| 3 | +# Language variables |
| 4 | +ENV LC_ALL=C.UTF-8 |
| 5 | +ENV LANG=C.UTF-8 |
| 6 | +ENV LANGUAGE=C.UTF-8 |
7 | 7 |
|
8 | | - # Installed needed OS packages. This is to support all |
9 | | - # the binary builds (torch, vision, audio, text, data) |
10 | | - RUN apt update && apt upgrade -y && \ |
| 8 | +# Install needed OS packages (supports binary builds for torch, vision, audio, etc.) |
| 9 | +RUN apt update && apt upgrade -y && \ |
11 | 10 | apt install -y \ |
12 | | - build-essential \ |
13 | | - sudo \ |
14 | | - autoconf \ |
15 | | - automake \ |
16 | | - bzip2 \ |
17 | | - curl \ |
18 | | - diffutils \ |
19 | | - file \ |
20 | | - git \ |
21 | | - make \ |
22 | | - patch \ |
23 | | - perl \ |
24 | | - unzip \ |
25 | | - util-linux \ |
26 | | - wget \ |
27 | | - which \ |
28 | | - xz-utils \ |
29 | | - less \ |
30 | | - zstd \ |
31 | | - cmake \ |
32 | | - python3 \ |
33 | | - python3-dev \ |
34 | | - python3-setuptools \ |
35 | | - python3-yaml \ |
36 | | - python3-typing-extensions \ |
37 | | - libblas-dev \ |
38 | | - libopenblas-dev \ |
39 | | - liblapack-dev \ |
40 | | - libatlas-base-dev \ |
41 | | - linux-headers-generic \ |
42 | | - zlib1g-dev \ |
43 | | - libbz2-1.0 \ |
44 | | - libncurses5-dev \ |
45 | | - libsqlite3-dev \ |
46 | | - libdb-dev \ |
47 | | - libpcap-dev \ |
48 | | - liblzma-dev \ |
49 | | - libffi-dev || echo "Some packages could not be installed but are non-critical." |
| 11 | + build-essential \ |
| 12 | + sudo \ |
| 13 | + autoconf \ |
| 14 | + automake \ |
| 15 | + bzip2 \ |
| 16 | + curl \ |
| 17 | + diffutils \ |
| 18 | + file \ |
| 19 | + git \ |
| 20 | + make \ |
| 21 | + patch \ |
| 22 | + perl \ |
| 23 | + unzip \ |
| 24 | + util-linux \ |
| 25 | + wget \ |
| 26 | + which \ |
| 27 | + xz-utils \ |
| 28 | + less \ |
| 29 | + zstd \ |
| 30 | + cmake \ |
| 31 | + python3 \ |
| 32 | + python3-dev \ |
| 33 | + python3-setuptools \ |
| 34 | + python3-yaml \ |
| 35 | + python3-typing-extensions \ |
| 36 | + libblas-dev \ |
| 37 | + libopenblas-dev \ |
| 38 | + liblapack-dev \ |
| 39 | + libatlas-base-dev \ |
| 40 | + linux-headers-generic \ |
| 41 | + zlib1g-dev \ |
| 42 | + libbz2-1.0 \ |
| 43 | + libncurses5-dev \ |
| 44 | + libsqlite3-dev \ |
| 45 | + libdb-dev \ |
| 46 | + libpcap-dev \ |
| 47 | + liblzma-dev \ |
| 48 | + libffi-dev || echo "Some packages could not be installed but are non-critical." |
50 | 49 |
|
51 | | - # Handle linux-headers installation gracefully |
52 | | - RUN apt-get update && \ |
53 | | - (apt install -y linux-headers-$(uname -r) || apt install -y linux-headers-generic || \ |
54 | | - echo "Skipping linux-headers installation as it is not critical") && \ |
55 | | - apt-get clean && rm -rf /var/lib/apt/lists/* |
| 50 | +# Handle linux-headers installation gracefully |
| 51 | +RUN apt-get update && \ |
| 52 | + (apt install -y linux-headers-$(uname -r) || apt install -y linux-headers-generic || \ |
| 53 | + echo "Skipping linux-headers installation as it is not critical") && \ |
| 54 | + apt-get clean && rm -rf /var/lib/apt/lists/* |
56 | 55 |
|
57 | | - # git236+ would refuse to run git commands in repos owned by other users |
58 | | - # Which causes version check to fail, as pytorch repo is bind-mounted into the image |
59 | | - # Override this behaviour by treating every folder as safe |
60 | | - # For more details see https://github.com/pytorch/pytorch/issues/78659#issuecomment-1144107327 |
61 | | - # Confirm git installation to prevent further issues |
62 | | - RUN git --version || (echo "Git installation failed!" && exit 1) |
63 | | - RUN git config --global --add safe.directory "*" |
| 56 | +# Confirm git installation and add safe.directory |
| 57 | +RUN git --version || (echo "Git installation failed!" && exit 1) |
| 58 | +RUN git config --global --add safe.directory "*" |
64 | 59 |
|
65 | | - FROM base as openssl |
66 | | - # Install openssl (this must precede `build python` step) |
67 | | - # (In order to have a proper SSL module, Python is compiled |
68 | | - # against a recent openssl [see env vars above], which is linked |
69 | | - # statically. We delete openssl afterwards.) |
| 60 | +# OpenSSL setup to ensure Python has SSL support |
| 61 | +FROM base as openssl |
| 62 | +# Set ulimit to avoid segmentation faults due to resource limits |
| 63 | +RUN ulimit -s unlimited |
70 | 64 |
|
71 | | - # Set ulimit to avoid segmentation fault due to resource limits |
72 | | - RUN ulimit -s unlimited |
| 65 | +ADD ./common/install_openssl-ppc64le.sh install_openssl.sh |
| 66 | +RUN export CFLAGS="-O0" && \ |
| 67 | + bash ./install_openssl.sh && rm install_openssl.sh |
| 68 | +ENV SSL_CERT_FILE=/opt/_internal/certs.pem |
73 | 69 |
|
74 | | - ADD ./common/install_openssl-ppc64le.sh install_openssl.sh |
75 | | - RUN export CFLAGS="-O0" && \ |
76 | | - bash ./install_openssl.sh && rm install_openssl.sh |
77 | | - ENV SSL_CERT_FILE=/opt/_internal/certs.pem |
| 70 | +# EPEL for cmake |
| 71 | +FROM base as patchelf |
| 72 | +# Install patchelf |
| 73 | +ADD ./common/install_patchelf.sh install_patchelf.sh |
| 74 | +RUN bash ./install_patchelf.sh && rm install_patchelf.sh |
| 75 | +RUN cp $(which patchelf) /patchelf |
78 | 76 |
|
79 | | - # EPEL for cmake |
80 | | - FROM base as patchelf |
81 | | - # Install patchelf |
82 | | - ADD ./common/install_patchelf.sh install_patchelf.sh |
83 | | - RUN bash ./install_patchelf.sh && rm install_patchelf.sh |
84 | | - RUN cp $(which patchelf) /patchelf |
| 77 | +# Python build stage |
| 78 | +FROM patchelf as python |
| 79 | +# Copy build scripts and install Python |
| 80 | +COPY manywheel/build_scripts /build_scripts |
| 81 | +ADD ./common/install_cpython.sh /build_scripts/install_cpython.sh |
| 82 | +RUN bash build_scripts/build.sh && rm -r build_scripts |
85 | 83 |
|
86 | | - FROM patchelf as python |
87 | | - # build python |
88 | | - COPY manywheel/build_scripts /build_scripts |
89 | | - ADD ./common/install_cpython.sh /build_scripts/install_cpython.sh |
90 | | - RUN bash build_scripts/build.sh && rm -r build_scripts |
| 84 | +# Final stage to copy over Python, OpenSSL, and patchelf |
| 85 | +FROM openssl as final |
| 86 | +COPY --from=python /opt/python /opt/python |
| 87 | +COPY --from=python /opt/_internal /opt/_internal |
| 88 | +COPY --from=python /opt/python/cp39-cp39/bin/auditwheel /usr/local/bin/auditwheel |
| 89 | +COPY --from=patchelf /usr/local/bin/patchelf /usr/local/bin/patchelf |
91 | 90 |
|
92 | | - FROM openssl as final |
93 | | - COPY --from=python /opt/python /opt/python |
94 | | - COPY --from=python /opt/_internal /opt/_internal |
95 | | - COPY --from=python /opt/python/cp39-cp39/bin/auditwheel /usr/local/bin/auditwheel |
96 | | - COPY --from=patchelf /usr/local/bin/patchelf /usr/local/bin/patchelf |
| 91 | +# Optional: Clean up to reduce image size |
| 92 | +RUN rm -rf /var/lib/apt/lists/* |
0 commit comments