-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathDockerfile.rpm
More file actions
119 lines (101 loc) · 5 KB
/
Copy pathDockerfile.rpm
File metadata and controls
119 lines (101 loc) · 5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# Copyright 2025- FlagOS Contributors
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
# Two-stage RPM build: produce the wheel and assemble the RPM on the same
# RPM-family base image. The wheel's Python ABI tag must match the Python
# interpreter used by rpmbuild/pip in the assembler stage.
#
# COPY-narrowing in wheel-builder mirrors Dockerfile.deb — packaging-only
# edits do NOT invalidate the wheel cache.
ARG RPM_BASE_IMAGE=fedora:43
# ---------- Stage 1: build the wheel ----------
FROM ${RPM_BASE_IMAGE} AS wheel-builder
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV PIP_ROOT_USER_ACTION=ignore
RUN dnf install -y --setopt=install_weak_deps=False \
python3 python3-pip python3-devel python3-setuptools python3-wheel \
gcc gcc-c++ make cmake ninja-build git \
zlib-devel libxml2-devel \
wget curl ca-certificates \
&& (dnf install -y --setopt=install_weak_deps=False json-devel \
|| dnf install -y --setopt=install_weak_deps=False nlohmann-json-devel) \
&& dnf clean all
RUN python3 -m pip install --no-cache-dir --upgrade pip setuptools wheel build
WORKDIR /src
# Dependency layer first so source edits don't invalidate it.
COPY python/requirements.txt /src/python/requirements.txt
RUN python3 -m pip install --no-cache-dir -r python/requirements.txt
# Narrow COPY: only the paths the wheel build needs, so packaging-only
# edits (specs, debian/, helpers) do NOT invalidate the ~50 min wheel
# layer. setup.py / pyproject.toml / MANIFEST.in live at the repo root
# since the post-#607 restructure.
COPY python /src/python
COPY third_party /src/third_party
COPY include /src/include
COPY lib /src/lib
COPY cmake /src/cmake
COPY bin /src/bin
COPY test /src/test
COPY unittest /src/unittest
COPY CMakeLists.txt pyproject.toml setup.py MANIFEST.in LICENSE README.md /src/
# Keep the tileir backend (GCC >= 13 + cuda-tile
# submodule) out of the distro build.
# The trailing rm keeps only /wheels in this layer: the CMake build
# tree and the LLVM tarball cache (~/.triton) would otherwise add
# several GB and push CI runners into ENOSPC.
RUN unset FLAGTREE_BACKEND && \
JSON_SYSPATH=/usr \
MAX_JOBS=4 python3 -m pip wheel . --no-build-isolation --no-deps -w /wheels -v && \
ls -lh /wheels/ && \
test -n "$(ls /wheels/flagtree-*.whl 2>/dev/null)" && \
rm -rf /src/build /root/.triton
# ---------- Stage 2: assemble the .rpm ----------
FROM ${RPM_BASE_IMAGE} AS rpm-assembler
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV PIP_ROOT_USER_ACTION=ignore
RUN dnf install -y --setopt=install_weak_deps=False \
rpm-build rpmdevtools \
python3 python3-pip python3-devel python3-setuptools python3-wheel \
&& dnf clean all
RUN rpmdev-setuptree
# openEuler images define %dist as empty (official .oe* tags are
# injected by EulerMaker); reconstruct it so local/CI builds get
# distro-tagged Release fields like official packages.
RUN if [ -z "$(rpm --eval '%{?dist}')" ]; then \
. /etc/os-release && \
case "${ID}" in \
openEuler) echo "%dist .oe$(echo "${VERSION_ID}" | tr -d '.')" >> /root/.rpmmacros ;; \
esac; \
fi
COPY packaging/rpm/specs/flagtree.spec /root/rpmbuild/SPECS/
COPY LICENSE /root/rpmbuild/SOURCES/LICENSE
COPY --from=wheel-builder /wheels /wheels
RUN rpmbuild -ba /root/rpmbuild/SPECS/flagtree.spec \
--define "flagtree_backend nvidia" \
--define "wheel_dir /wheels" && \
ls -lh /root/rpmbuild/RPMS/x86_64/
# Smoke test: install the freshly built rpm and import the package.
# Catches the "installs fine, fails at import" class (missing libs,
# bad rpath, glibc mismatch) that rpmbuild alone cannot see.
RUN dnf install -y /root/rpmbuild/RPMS/x86_64/python3-flagtree-*.x86_64.rpm && \
python3 -c "import triton; print(getattr(triton, '__version__', 'import ok'))"
# ---------- Stage 3: extract just the rpms ----------
FROM scratch AS rpm-output
COPY --from=rpm-assembler /root/rpmbuild/RPMS/x86_64/python3-flagtree-*.rpm /output/
COPY --from=rpm-assembler /root/rpmbuild/SRPMS/python3-flagtree-*.src.rpm /output/