Skip to content

Commit 437b02c

Browse files
raptorsunsyedriko
authored andcommitted
OLS-1676: Create RAG BYOK tool image through konflux
Signed-off-by: Haoyu Sun <[email protected]>
1 parent 523d9dc commit 437b02c

File tree

4 files changed

+40
-10
lines changed

4 files changed

+40
-10
lines changed

.tekton/lightspeed-rag-tool-pull-request.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ metadata:
88
build.appstudio.redhat.com/target_branch: '{{target_branch}}'
99
pipelinesascode.tekton.dev/cancel-in-progress: "true"
1010
pipelinesascode.tekton.dev/max-keep-runs: "3"
11-
pipelinesascode.tekton.dev/on-cel-expression: event == "pull_request" && target_branch
12-
== "main"
11+
pipelinesascode.tekton.dev/on-cel-expression: |
12+
event == "pull_request" &&
13+
target_branch == "main" &&
14+
(".tekton/lightspeed-rag-tool-pull-request.yaml".pathChanged() || "artifacts.lock.yaml".pathChanged() || "rpms.lock.yaml".pathChanged() || "requirements*".pathChanged() || "byok/***".pathChanged() || "embeddings_model/***".pathChanged())
1315
creationTimestamp: null
1416
labels:
1517
appstudio.openshift.io/application: rag-tool
@@ -29,6 +31,11 @@ spec:
2931
value: 5d
3032
- name: dockerfile
3133
value: byok/Containerfile.tool
34+
- name: hermetic
35+
value: "true"
36+
- name: prefetch-input
37+
value: '[{"type": "generic", "path": "."}, {"type": "rpm", "path": "."}, {"type":
38+
"pip", "path": ".", "allow_binary": "true", "requirements_files": ["requirements.gpu.txt"]}]'
3239
pipelineSpec:
3340
description: |
3441
This pipeline is ideal for building container images from a Containerfile while maintaining trust after pipeline customization.
@@ -181,6 +188,8 @@ spec:
181188
value: $(params.output-image).prefetch
182189
- name: ociArtifactExpiresAfter
183190
value: $(params.image-expires-after)
191+
- name: dev-package-managers
192+
value: "true"
184193
runAfter:
185194
- clone-repository
186195
taskRef:

.tekton/lightspeed-rag-tool-push.yaml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ metadata:
77
build.appstudio.redhat.com/target_branch: '{{target_branch}}'
88
pipelinesascode.tekton.dev/cancel-in-progress: "false"
99
pipelinesascode.tekton.dev/max-keep-runs: "3"
10-
pipelinesascode.tekton.dev/on-cel-expression: event == "push" && target_branch
11-
== "main"
10+
pipelinesascode.tekton.dev/on-cel-expression: |
11+
event == "push" &&
12+
target_branch == "main" &&
13+
(".tekton/lightspeed-rag-tool-on-push.yaml".pathChanged() || "artifacts.lock.yaml".pathChanged() || "rpms.lock.yaml".pathChanged() || "requirements*".pathChanged() || "byok/***".pathChanged() || "embeddings_model/***".pathChanged())
1214
creationTimestamp: null
1315
labels:
1416
appstudio.openshift.io/application: rag-tool
@@ -26,6 +28,11 @@ spec:
2628
value: quay.io/redhat-user-workloads/crt-nshift-lightspeed-tenant/lightspeed-rag-tool:{{revision}}
2729
- name: dockerfile
2830
value: byok/Containerfile.tool
31+
- name: hermetic
32+
value: "true"
33+
- name: prefetch-input
34+
value: '[{"type": "generic", "path": "."}, {"type": "rpm", "path": "."}, {"type":
35+
"pip", "path": ".", "allow_binary": "true", "requirements_files": ["requirements.gpu.txt"]}]'
2936
pipelineSpec:
3037
description: |
3138
This pipeline is ideal for building container images from a Containerfile while maintaining trust after pipeline customization.
@@ -178,6 +185,8 @@ spec:
178185
value: $(params.output-image).prefetch
179186
- name: ociArtifactExpiresAfter
180187
value: $(params.image-expires-after)
188+
- name: dev-package-managers
189+
value: "true"
181190
runAfter:
182191
- clone-repository
183192
taskRef:

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,11 @@ help: ## Show this help screen
6060
@grep -E '^[ a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
6161
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-25s\033[0m %s\n", $$1, $$2}'
6262
@echo ''
63+
64+
model-safetensors: ## Download model.safetensors to embeddings_model
65+
@if [ ! -f embeddings_model/model.safetensors ]; then \
66+
echo "Downloading model.safetensors..."; \
67+
wget "https://huggingface.co/sentence-transformers/all-mpnet-base-v2/resolve/9a3225965996d404b775526de6dbfe85d3368642/model.safetensors" -O embeddings_model/model.safetensors; \
68+
else \
69+
echo "model.safetensors already exists. Skipping download."; \
70+
fi

byok/Containerfile.tool

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
ARG BYOK_TOOL_IMAGE=quay.io/$USERNAME/tool:latest
22
ARG UBI_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi:latest
3+
ARG HERMETIC=false
34
FROM ${UBI_BASE_IMAGE}
45
ARG LOG_LEVEL=info
56
ARG OUT_IMAGE_TAG=byok-image
67
ARG VECTOR_DB_INDEX=vector_db_index
78
ARG BYOK_TOOL_IMAGE
89
ARG UBI_BASE_IMAGE
9-
RUN dnf install -y buildah python3.11 python3.11-pip wget
10+
ARG HERMETIC
11+
RUN dnf install -y buildah python3.11 python3.11-pip
1012

1113
USER 0
1214
WORKDIR /workdir
1315

14-
COPY requirements.cpu.txt .
15-
RUN pip3.11 install --upgrade pip && pip3.11 install --no-cache-dir -r requirements.cpu.txt
16+
COPY requirements.gpu.txt .
17+
RUN pip3.11 install --no-cache-dir --no-deps -r requirements.gpu.txt
1618

1719
COPY embeddings_model ./embeddings_model
18-
RUN cd embeddings_model && if [ ! -f embeddings_model/model.safetensors ]; then \
19-
wget -q https://huggingface.co/sentence-transformers/all-mpnet-base-v2/resolve/9a3225965996d404b775526de6dbfe85d3368642/model.safetensors; \
20+
RUN cd embeddings_model; if [ "$HERMETIC" == "true" ] && [ ! -f embeddings_model/model.safetensors ]; then \
21+
cp /cachi2/output/deps/generic/model.safetensors model.safetensors; \
22+
elif [ ! -f embeddings_model/model.safetensors ]; then \
23+
curl -L -O https://huggingface.co/sentence-transformers/all-mpnet-base-v2/resolve/9a3225965996d404b775526de6dbfe85d3368642/model.safetensors; \
2024
fi
21-
COPY byok/generate_embeddings_tool.py byok/Containerfile.output .
25+
COPY byok/generate_embeddings_tool.py byok/Containerfile.output ./
2226

2327
ENV _BUILDAH_STARTED_IN_USERNS=""
2428
ENV BUILDAH_ISOLATION=chroot

0 commit comments

Comments
 (0)