Skip to content

Commit

Permalink
Merge pull request containers#154 from rhatdan/rag
Browse files Browse the repository at this point in the history
Merge changes for chatbot into rag
  • Loading branch information
rhatdan authored Apr 4, 2024
2 parents d0ca37a + f6c9f5c commit e630e7c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 6 deletions.
13 changes: 9 additions & 4 deletions recipes/natural_language_processing/rag/Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,35 @@
APP=rag
CHROMADBIMAGE ?= quay.io/ai-lab/chromadb:latest
MODELIMAGE ?= quay.io/ai-lab/mistral-7b-instruct:latest
APPIMAGE ?= quay.io/ai-lab/${APP}:latest
SERVERIMAGE ?= quay.io/ai-lab/llamacpp-python:latest
SSHPUBKEY ?= $(shell cat ${HOME}/.ssh/id_rsa.pub;)
BOOTCIMAGE ?= quay.io/ai-lab/${APP}-bootc:latest

.PHONY: build
build:
podman build -f builds/Containerfile -t ghcr.io/ai-lab-recipes/${APP} .
podman build -f builds/Containerfile -t ${APPIMAGE} .

.PHONY: bootc
bootc:
sudo podman build --cap-add SYS_ADMIN --build-arg "SSHPUBKEY=$(SSHPUBKEY)" -f bootc/Containerfile -t ghcr.io/ai-lab-recipes/${APP}-bootc .
podman build --cap-add SYS_ADMIN --build-arg "SSHPUBKEY=$(SSHPUBKEY)" -f bootc/Containerfile -t ${BOOTCIMAGE} .

.PHONY: quadlet
quadlet:
# Modify quadlet files to match the server, model and app image
# Modify quadlet files to match the server, model and app image
mkdir -p build
sed -e "s|SERVERIMAGE|${SERVERIMAGE}|" \
-e "s|APPIMAGE|${APPIMAGE}|g" \
-e "s|MODELIMAGE|${MODELIMAGE}|g" \
-e "s|CHROMADBIMAGE|${CHROMADBIMAGE}|g" \
quadlet/${APP}.image \
> build/${APP}.image
sed -e "s|SERVERIMAGE|${SERVERIMAGE}|" \
-e "s|APPIMAGE|${APPIMAGE}|g" \
-e "s|MODELIMAGE|${MODELIMAGE}|g" \
-e "s|CHROMADBIMAGE|${CHROMADBIMAGE}|g" \
quadlet/${APP}.yaml \
> /tmp/${APP}.yaml
> build/${APP}.yaml
cp quadlet/${APP}.kube build/${APP}.kube

.PHONY: install
Expand Down
21 changes: 19 additions & 2 deletions recipes/natural_language_processing/rag/bootc/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,38 @@ ARG RECIPE=rag
ARG MODELIMAGE=quay.io/ai-lab/mistral-7b-instruct:latest
ARG APPIMAGE=quay.io/ai-lab/${RECIPE}:latest
ARG SERVERIMAGE=quay.io/ai-lab/llamacpp-python:latest
ARG CHROMADBImage=quay.io/ai-lab/chromadb

# Add quadlet files to setup system to automatically run AI application on boot
COPY quadlet/${RECIPE}.kube quadlet/${RECIPE}.yaml quadlet/${RECIPE}.image /usr/share/containers/systemd
COPY quadlet/${RECIPE}.kube quadlet/${RECIPE}.yaml /usr/share/containers/systemd

# Modify quadlet files to match the server, model and app image
RUN sed -e "s|SERVERIMAGE|${SERVERIMAGE}|" \
-e "s|APPIMAGE|${APPIMAGE}|g" \
-e "s|MODELIMAGE|${MODELIMAGE}|g" \
-i \
/usr/share/containers/systemd/${RECIPE}.image \
/usr/share/containers/systemd/${RECIPE}.yaml

# Because images are prepulled, no need for .image quadlet
# COPY quadlet/${RECIPE}.image /usr/share/containers/systemd
# RUN sed -e "s|SERVERIMAGE|${SERVERIMAGE}|" \
# -e "s|APPIMAGE|${APPIMAGE}|g" \
# -e "s|MODELIMAGE|${MODELIMAGE}|g" \
# -i \
# /usr/share/containers/systemd/${RECIPE}.image

# Setup /usr/lib/containers/storage as an additional store for images.
# Remove once the base images have this set by default.
RUN sed -i -e '/additionalimage.*/a "/usr/lib/containers/storage",' \
/etc/containers/storage.conf

# Added for running as an OCI Container to prevent Overlay on Overlay issues.
VOLUME /var/lib/containers

# Prepull the model, model_server & application images to populate the system.
RUN podman pull --root /usr/lib/containers/storage ${SERVERIMAGE}
RUN podman pull --root /usr/lib/containers/storage ${APPIMAGE}
RUN podman pull --root /usr/lib/containers/storage ${MODELIMAGE}
RUN podman pull --root /usr/lib/containers/storage ${CHROMADBImage}

RUN podman system reset --force 2>/dev/null
10 changes: 10 additions & 0 deletions recipes/natural_language_processing/rag/quadlet/rag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ spec:
hostPort: 8501
securityContext:
runAsNonRoot: true
- env:
- name: CHROMADB_ENDPOINT
value: http://0.0.0.0:800O/v1
image: CHROMADBIMAGE
name: rag-chromadb
ports:
- containerPort: 8000
hostPort: 8000
securityContext:
runAsNonRoot: true
- env:
- name: HOST
value: 0.0.0.0
Expand Down
6 changes: 6 additions & 0 deletions vector_dbs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
APP ?= chromadb
APPIMAGE ?= quay.io/ai-lab/${APP}:latest

.PHONY: build
build:
podman build -f chromadb/Containerfile -t ${APPIMAGE} .

0 comments on commit e630e7c

Please sign in to comment.