Skip to content

Commit 52e8cfd

Browse files
Merge pull request #362 from syedriko/syedriko-ols-1676
OLS-1676: Create RAG BYOK tool image through Konflux
2 parents a65af97 + 6496953 commit 52e8cfd

File tree

8 files changed

+346
-107
lines changed

8 files changed

+346
-107
lines changed

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

Lines changed: 16 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,16 @@ spec:
2931
value: 5d
3032
- name: dockerfile
3133
value: byok/Containerfile.tool
34+
- name: hermetic
35+
value: "true"
36+
- name: build-args
37+
value:
38+
- HERMETIC=true
39+
- name: build-source-image
40+
value: "true"
41+
- name: prefetch-input
42+
value: '[{"type": "generic", "path": "."}, {"type": "rpm", "path": "."}, {"type":
43+
"pip", "path": ".", "allow_binary": "true", "requirements_files": ["requirements.gpu.txt"]}]'
3244
pipelineSpec:
3345
description: |
3446
This pipeline is ideal for building container images from a Containerfile while maintaining trust after pipeline customization.
@@ -181,6 +193,8 @@ spec:
181193
value: $(params.output-image).prefetch
182194
- name: ociArtifactExpiresAfter
183195
value: $(params.image-expires-after)
196+
- name: dev-package-managers
197+
value: "true"
184198
runAfter:
185199
- clone-repository
186200
taskRef:

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

Lines changed: 16 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,16 @@ 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: build-args
34+
value:
35+
- HERMETIC=true
36+
- name: build-source-image
37+
value: "true"
38+
- name: prefetch-input
39+
value: '[{"type": "generic", "path": "."}, {"type": "rpm", "path": "."}, {"type":
40+
"pip", "path": ".", "allow_binary": "true", "requirements_files": ["requirements.gpu.txt"]}]'
2941
pipelineSpec:
3042
description: |
3143
This pipeline is ideal for building container images from a Containerfile while maintaining trust after pipeline customization.
@@ -178,6 +190,8 @@ spec:
178190
value: $(params.output-image).prefetch
179191
- name: ociArtifactExpiresAfter
180192
value: $(params.image-expires-after)
193+
- name: dev-package-managers
194+
value: "true"
181195
runAfter:
182196
- clone-repository
183197
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.output

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ARG BYOK_TOOL_IMAGE=quay.io/$USERNAME/tool:latest
1+
ARG BYOK_TOOL_IMAGE=registry.redhat.io/lightspeed-rag-tool-tech-preview/lightspeed-rag-tool-rhel9:latest
22
ARG UBI_BASE_IMAGE=registry.access.redhat.com/ubi9/ubi:latest
33
FROM ${BYOK_TOOL_IMAGE} as tool
44
ARG UBI_BASE_IMAGE

byok/Containerfile.tool

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,52 @@
1-
ARG BYOK_TOOL_IMAGE=quay.io/$USERNAME/tool:latest
1+
ARG BYOK_TOOL_IMAGE=registry.redhat.io/lightspeed-rag-tool-tech-preview/lightspeed-rag-tool-rhel9: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+
ENV HERMETIC=$HERMETIC
21+
RUN cd embeddings_model; \
22+
if [ ! -f embeddings_model/model.safetensors ]; then \
23+
if [ "$HERMETIC" == "true" ]; then \
24+
cp /cachi2/output/deps/generic/model.safetensors model.safetensors; \
25+
else \
26+
curl -L -O https://huggingface.co/sentence-transformers/all-mpnet-base-v2/resolve/9a3225965996d404b775526de6dbfe85d3368642/model.safetensors; \
27+
fi \
2028
fi
21-
COPY byok/generate_embeddings_tool.py byok/Containerfile.output .
29+
COPY byok/generate_embeddings_tool.py byok/Containerfile.output ./
30+
31+
# this directory is checked by ecosystem-cert-preflight-checks task in Konflux
32+
RUN mkdir /licenses
33+
COPY LICENSE /licenses/
34+
35+
# Labels for enterprise contract
36+
LABEL com.redhat.component=openshift-lightspeed-rag-content
37+
LABEL description="Red Hat OpenShift Lightspeed BYO Knowledge Tools"
38+
LABEL distribution-scope=private
39+
LABEL io.k8s.description="Red Hat OpenShift Lightspeed BYO Knowledge Tools"
40+
LABEL io.k8s.display-name="Openshift Lightspeed BYO Knowledge Tools"
41+
LABEL io.openshift.tags="openshift,lightspeed,ai,assistant,rag"
42+
LABEL name=openshift-lightspeed-rag-content
43+
LABEL release=0.0.1
44+
LABEL url="https://github.com/openshift/lightspeed-rag-content"
45+
LABEL vendor="Red Hat, Inc."
46+
LABEL version=0.0.1
47+
LABEL summary="Red Hat OpenShift Lightspeed BYO Knowledge Tools"
48+
49+
USER 65532:65532
2250

2351
ENV _BUILDAH_STARTED_IN_USERNS=""
2452
ENV BUILDAH_ISOLATION=chroot

rpms.in.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
packages: [python3.11, python3.11-pip, libcudnn9, libnccl, libcusparselt0]
1+
packages: [buildah, python3.11, python3.11-pip, libcudnn9, libnccl, libcusparselt0]
22
contentOrigin:
33
repofiles: ["./ubi.repo", "./cuda.repo"]
4+
arches: [x86_64]

0 commit comments

Comments
 (0)