Skip to content

Commit f3aa2a8

Browse files
committed
konflux: hermetic build
Signed-off-by: Haoyu Sun <[email protected]>
1 parent 7b14a32 commit f3aa2a8

File tree

10 files changed

+2975
-53
lines changed

10 files changed

+2975
-53
lines changed

.tekton/lightspeed-stack-pull-request.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,17 @@ spec:
2727
value: quay.io/redhat-user-workloads/lightspeed-core-tenant/lightspeed-stack:on-pr-{{revision}}
2828
- name: image-expires-after
2929
value: 5d
30+
# todo: add arm64. refer to https://konflux.pages.redhat.com/docs/users/getting-started/multi-platform-builds.html#arm64-2
3031
- name: build-platforms
3132
value:
3233
- linux/x86_64
34+
# todo: change on-push pipeline,too
35+
- name: build-source-image
36+
value: 'true'
37+
- name: prefetch-input
38+
value: '[{"type": "rpm", "path": "."}, {"type": "pip", "path": ".", "allow_binary": "true", "requirements_files": ["requirements.txt", "requirements.hermetic.txt"]}]'
39+
- name: hermetic
40+
value: 'true'
3341
- name: dockerfile
3442
value: Containerfile
3543
pipelineSpec:

.tekton/lightspeed-stack-push.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,16 @@ spec:
2424
value: '{{revision}}'
2525
- name: output-image
2626
value: quay.io/redhat-user-workloads/lightspeed-core-tenant/lightspeed-stack:{{revision}}
27+
# todo: add arm64. refer to https://konflux.pages.redhat.com/docs/users/getting-started/multi-platform-builds.html#arm64-2
2728
- name: build-platforms
2829
value:
2930
- linux/x86_64
31+
- name: build-source-image
32+
value: 'true'
33+
- name: prefetch-input
34+
value: '[{"type": "rpm", "path": "."}, {"type": "pip", "path": ".", "allow_binary": "true", "requirements_files": ["requirements.txt", "requirements.hermetic.txt"]}]'
35+
- name: hermetic
36+
value: 'true'
3037
- name: dockerfile
3138
value: Containerfile
3239
pipelineSpec:

Containerfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,24 @@ RUN dnf --disablerepo="*" --enablerepo="ubi-9-appstream-rpms" --enablerepo="ubi-
1919
# Install uv package manager
2020
RUN pip3.12 install "uv==0.8.15"
2121

22+
# Install pdm and pdm-backend for hermetic builds
23+
RUN if [ -f /cachi2/cachi2.env ]; then pip3.12 install "pdm>=2.21.0" "pdm-backend"; fi
24+
2225
# Add explicit files and directories
2326
# (avoid accidental inclusion of local directories or env files or credentials)
2427
COPY ${LSC_SOURCE_DIR}/src ./src
25-
COPY ${LSC_SOURCE_DIR}/pyproject.toml ${LSC_SOURCE_DIR}/LICENSE ${LSC_SOURCE_DIR}/README.md ${LSC_SOURCE_DIR}/uv.lock ./
28+
COPY ${LSC_SOURCE_DIR}/pyproject.toml ${LSC_SOURCE_DIR}/LICENSE ${LSC_SOURCE_DIR}/README.md ${LSC_SOURCE_DIR}/uv.lock ${LSC_SOURCE_DIR}/requirements.txt ./
2629

2730
# Bundle additional dependencies for library mode.
28-
RUN uv sync --locked --no-dev --group llslibdev
31+
# Source cachi2 environment for hermetic builds if available, otherwise use normal installation
32+
# cachi2.env has these env vars:
33+
# PIP_FIND_LINKS=/cachi2/output/deps/pip
34+
# PIP_NO_INDEX=true
35+
RUN if [ -f /cachi2/cachi2.env ]; then \
36+
. /cachi2/cachi2.env && uv venv --seed --no-index --find-links ${PIP_FIND_LINKS} && . .venv/bin/activate && pip install --no-index --find-links ${PIP_FIND_LINKS} -r requirements.txt; \
37+
else \
38+
uv sync --locked --no-dev --group llslibdev; \
39+
fi
2940

3041
# Explicitly remove some packages to mitigate some CVEs
3142
# - GHSA-wj6h-64fc-37mp: python-ecdsa package won't fix it upstream.

pyproject.toml

Lines changed: 60 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,23 @@ Issues = "https://github.com/lightspeed-core/lightspeed-stack/issues"
8787
name = "pytorch-cpu"
8888
url = "https://download.pytorch.org/whl/cpu"
8989
explicit = true
90+
91+
[[tool.uv.index]]
92+
name = "pypi-default"
93+
url = "https://pypi.org/simple"
94+
explicit = true
9095
[tool.uv.sources]
91-
torch = [{ index = "pytorch-cpu" }]
96+
torch = [
97+
{ index = "pytorch-cpu", group = "llslibdev" },
98+
{ index = "pypi-default", group = "llslibdev-hermetic" }
99+
]
100+
[tool.uv]
101+
conflicts = [
102+
[
103+
{ group = "llslibdev" },
104+
{ group = "llslibdev-hermetic" },
105+
],
106+
]
92107

93108
[dependency-groups]
94109
dev = [
@@ -159,6 +174,50 @@ llslibdev = [
159174
"blobfile>=3.0.0",
160175
"psutil>=7.0.0",
161176
]
177+
llslibdev-hermetic = [
178+
# the same as llslibdev, just using default index.
179+
"matplotlib>=3.10.0",
180+
"pillow>=11.1.0",
181+
"pandas>=2.2.3",
182+
"scikit-learn>=1.5.2",
183+
"psycopg2-binary>=2.9.10",
184+
# API eval: inline::meta-reference
185+
"tree_sitter>=0.24.0",
186+
"pythainlp>=3.0.10",
187+
"langdetect>=1.0.9",
188+
"emoji>=2.1.0",
189+
"nltk>=3.8.1",
190+
# API inference: remote::gemini
191+
"litellm>=1.75.5.post1",
192+
# API inference: inline::sentence-transformers
193+
"sentence-transformers>=5.0.0",
194+
# API vector_io: inline::faiss
195+
"faiss-cpu>=1.11.0",
196+
# API scoring: inline::basic
197+
"requests>=2.32.4",
198+
# API datasetio: inline::localfs
199+
"aiosqlite>=0.21.0",
200+
# API datasetio: remote::huggingface
201+
"datasets>=3.6.0",
202+
# API telemetry: inline::meta-reference
203+
"opentelemetry-sdk>=1.34.1",
204+
"opentelemetry-exporter-otlp>=1.34.1",
205+
# API tool_runtime: inline::rag-runtime
206+
"transformers>=4.34.0",
207+
"numpy==2.2.6",
208+
# API tool_runtime: remote::model-context-protocol
209+
"mcp>=1.9.4",
210+
# API post_training: inline::huggingface
211+
"torch==2.7.1; sys_platform == 'linux'",
212+
"trl>=0.18.2",
213+
"peft>=0.15.2",
214+
# Other
215+
"autoevals>=0.0.129",
216+
"fire>=0.7.0",
217+
"opentelemetry-instrumentation>=0.55b0",
218+
"blobfile>=3.0.0",
219+
"psutil>=7.0.0",
220+
]
162221

163222
build = [
164223
"build>=1.2.2.post1",

requirements.hermetic.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
uv==0.8.15
2+
pdm==2.26.1
3+
pdm-backend==2.4.6
4+
pip==24.2

0 commit comments

Comments
 (0)