Skip to content

Commit

Permalink
Merge pull request #200 from rhatdan/codegen
Browse files Browse the repository at this point in the history
fix up renaming of IMAGE Constants.
  • Loading branch information
sallyom authored Apr 9, 2024
2 parents fc5e832 + 1700121 commit 056c2db
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 64 deletions.
1 change: 1 addition & 0 deletions .github/workflows/chatbot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ jobs:

- name: Run Functional Tests
working-directory: ./recipes/natural_language_processing/chatbot
shell: bash
run: make functional-tests

- name: Login to Registry
Expand Down
30 changes: 27 additions & 3 deletions recipes/common/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ REGISTRY ?= quay.io
REGISTRY_ORG ?= ai-lab

IMAGE_NAME ?= $(REGISTRY_ORG)/${APP}:latest
APP_IMAGE ?= $(REGISTRY)/$(IMAGE_NAME)
CHROMADB_IMAGE ?= $(REGISTRY)/$(REGISTRY_ORG)/chromadb:latest
MODEL_IMAGE ?= $(REGISTRY)/$(REGISTRY_ORG)/mistral-7b-instruct:latest
APP_IMAGE ?= $(REGISTRY)/$(IMAGE_NAME)
SERVER_IMAGE ?= $(REGISTRY)/$(REGISTRY_ORG)/llamacpp-python:latest

SSH_PUBKEY ?= $(shell cat ${HOME}/.ssh/id_rsa.pub;)
Expand All @@ -13,6 +13,19 @@ BOOTC_IMAGE ?= quay.io/$(REGISTRY_ORG)/${APP}-bootc:latest
FROM ?=
ARCH ?=

ROOTLESS_AUTH_JSON=${XDG_RUNTIME_DIR}/containers/auth.json
ROOTFUL_AUTH_JSON=/run/containers/0/auth.json
NONLINUX_AUTH_JSON=${HOME}/.config/containers/auth.json
AUTH_JSON=

ifneq ("$(wildcard $(NONLINUX_AUTH_JSON))","")
AUTH_JSON=$(NONINUX_AUTH_JSON);
else ifneq ("$(wildcard $(ROOTLESS_AUTH_JSON))","")
AUTH_JSON=$(ROOTLESS_AUTH_JSON);
else ifneq ("$(wildcard $(ROOTFUL_AUTH_JSON))","")
AUTH_JSON=$(ROOTFUL_AUTH_JSON);
endif

CHROMEDRIVER_VERSION := 103.0.5060.53
CHROMEDRIVER_MIRROR := https://chromedriver.storage.googleapis.com
CHROMEDRIVER_DOWNLOAD_PATH :=
Expand All @@ -37,11 +50,22 @@ UNZIP_EXISTS ?= $(shell command -v unzip)

.PHONY: build
build:
podman build $${ARCH:+--arch $${ARCH}} $${FROM:+--from $${FROM}} -f builds/Containerfile -t ${APP_IMAGE} .
podman build --squash-all $${ARCH:+--arch $${ARCH}} $${FROM:+--from $${FROM}} -f builds/Containerfile -t ${APP_IMAGE} .

.PHONY: bootc
bootc: quadlet
podman build $${ARCH:+--arch $${ARCH}} $${FROM:+--from $${FROM}} --cap-add SYS_ADMIN --build-arg "SSH_PUBKEY=$(SSH_PUBKEY)" -f bootc/Containerfile -t ${BOOTC_IMAGE} .
podman build \
$${ARCH:+--arch $${ARCH}} \
$${FROM:+--from $${FROM}} \
$${AUTH_JSON:+-v $${AUTH_JSON}:/run/containers/0/auth.json} \
--cap-add SYS_ADMIN \
--build-arg MODEL_IMAGE=$(MODEL_IMAGE) \
--build-arg APP_IMAGE=$(APP_IMAGE) \
--build-arg SERVER_IMAGE=$(SERVER_IMAGE) \
--build-arg "SSHPUBKEY=$(SSHPUBKEY)" \
-v /etc/containers/policy.json:/etc/containers/policy.json \
-f bootc/Containerfile \
-t ${BOOTC_IMAGE} .
@echo ""
@echo "Successfully built bootc image '${BOOTC_IMAGE}'."
@echo "You may now convert the image into a disk image via bootc-image-builder"
Expand Down
1 change: 1 addition & 0 deletions recipes/natural_language_processing/chatbot/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
SHELL := /bin/bash
APP ?= chatbot
PORT ?= 8501

Expand Down
12 changes: 6 additions & 6 deletions recipes/natural_language_processing/chatbot/bootc/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ RUN mkdir /usr/etc-system && \
echo ${SSHPUBKEY} > /usr/etc-system/root.keys && chmod 0600 /usr/etc-system/root.keys

ARG RECIPE=chatbot
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 MODEL_IMAGE=quay.io/ai-lab/mistral-7b-instruct:latest
ARG APP_IMAGE=quay.io/ai-lab/${RECIPE}:latest
ARG SERVER_IMAGE=quay.io/ai-lab/llamacpp-python:latest

# Add quadlet files to setup system to automatically run AI application on boot
COPY build/${RECIPE}.kube build/${RECIPE}.yaml /usr/share/containers/systemd
Expand All @@ -37,8 +37,8 @@ VOLUME /var/lib/containers
# Prepull the model, model_server & application images to populate the system.
# Comment the pull commands to keep bootc image smaller.
# The quadlet .image file added above pulls following images with service startup
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 ${SERVER_IMAGE}
RUN podman pull --root /usr/lib/containers/storage ${APP_IMAGE}
RUN podman pull --root /usr/lib/containers/storage ${MODEL_IMAGE}

RUN podman system reset --force 2>/dev/null
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
WantedBy=chatbot.service

[Image]
Image=APPIMAGE
Image=MODELIMAGE
Image=SERVERIMAGE
Image=APP_IMAGE
Image=MODEL_IMAGE
Image=SERVER_IMAGE
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
spec:
initContainers:
- name: model-file
image: MODELIMAGE
image: MODEL_IMAGE
command: ['/usr/bin/install', "/model/model.file", "/shared/"]
volumeMounts:
- name: model-file
Expand All @@ -16,7 +16,7 @@ spec:
- env:
- name: MODEL_SERVICE_ENDPOINT
value: http://0.0.0.0:8001/v1
image: APPIMAGE
image: APP_IMAGE
name: chatbot-inference
ports:
- containerPort: 8501
Expand All @@ -30,7 +30,7 @@ spec:
value: 8001
- name: MODEL_PATH
value: /model/model.file
image: SERVERIMAGE
image: SERVER_IMAGE
name: chatbot-model-service
ports:
- containerPort: 8001
Expand Down
4 changes: 2 additions & 2 deletions recipes/natural_language_processing/codegen/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ and run:


```
make BOOTCIMAGE=quay.io/your/codegen-bootc:latest bootc
make BOOTC_IMAGE=quay.io/your/codegen-bootc:latest bootc
```

Substituting the bootc/Containerfile FROM command is simple using the Makefile FROM option.

```
make FROM=registry.redhat.io/rhel9-beta/rhel-bootc:9.4 BOOTCIMAGE=quay.io/your/codegen-bootc:latest bootc
make FROM=registry.redhat.io/rhel9-beta/rhel-bootc:9.4 BOOTC_IMAGE=quay.io/your/codegen-bootc:latest bootc
```

The magic happens when you have a bootc enabled system running. If you do, and you'd like to update the operating system to the OS you just built
Expand Down
24 changes: 12 additions & 12 deletions recipes/natural_language_processing/codegen/bootc/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,25 +19,25 @@ RUN mkdir /usr/etc-system && \
# pre-pulled here

ARG RECIPE=codegen
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 MODEL_IMAGE=quay.io/ai-lab/mistral-7b-instruct:latest
ARG APP_IMAGE=quay.io/ai-lab/${RECIPE}:latest
ARG SERVER_IMAGE=quay.io/ai-lab/llamacpp-python:latest

# Add quadlet files to setup system to automatically run AI application on boot
COPY build/${RECIPE}.kube build/${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" \
RUN sed -e "s|SERVER_IMAGE|${SERVER_IMAGE}|" \
-e "s|APP_IMAGE|${APP_IMAGE}|g" \
-e "s|MODEL_IMAGE|${MODEL_IMAGE}|g" \
-i \
/usr/share/containers/systemd/${RECIPE}.yaml

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

Expand All @@ -50,8 +50,8 @@ RUN sed -i -e '/additionalimage.*/a "/usr/lib/containers/storage",' \
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 ${SERVER_IMAGE}
RUN podman pull --root /usr/lib/containers/storage ${APP_IMAGE}
RUN podman pull --root /usr/lib/containers/storage ${MODEL_IMAGE}

RUN podman system reset --force 2>/dev/null
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
WantedBy=codegen.service

[Image]
Image=quay.io/redhat-et/locallm-codellama-7b-gguf:latest
Image=quay.io/ai-lab/llamacpp-python:latest
Image=quay.io/redhat-et/locallm-codegen:latest
Image=APP_IMAGE
Image=MODEL_IMAGE
Image=SERVER_IMAGE

Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ apiVersion: v1
kind: Pod
metadata:
labels:
app: codegen-langchain
name: codegen-langchain
app: codegen
name: codegen
spec:
initContainers:
- name: model-file
Expand All @@ -16,7 +16,7 @@ spec:
- env:
- name: MODEL_SERVICE_ENDPOINT
value: http://0.0.0.0:8001/v1
image: quay.io/redhat-et/locallm-codegen:latest
image: APP_IMAGE
name: codegen-inference
ports:
- containerPort: 8501
Expand All @@ -30,7 +30,7 @@ spec:
value: 8001
- name: MODEL_PATH
value: /model/codellama-7b-instruct.Q4_K_M.gguf
image: quay.io/redhat-et/locallm-model-service:latest
image: SERVICE_IMAGE
name: codegen-model-service
ports:
- containerPort: 8001
Expand Down
6 changes: 3 additions & 3 deletions recipes/natural_language_processing/rag/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ Now that the Model Service is running we want to build and deploy our AI Applica

```bash
cd rag
make APPIMAGE=rag build
make APP_IMAGE=rag build
```

### Deploy the AI Application
Expand Down Expand Up @@ -158,13 +158,13 @@ and run:


```
make BOOTCIMAGE=quay.io/your/rag-bootc:latest bootc
make BOOTC_IMAGE=quay.io/your/rag-bootc:latest bootc
```

Substituting the bootc/Containerfile FROM command is simple using the Makefile FROM option.

```
make FROM=registry.redhat.io/rhel9-beta/rhel-bootc:9.4 BOOTCIMAGE=quay.io/your/rag-bootc:latest bootc
make FROM=registry.redhat.io/rhel9-beta/rhel-bootc:9.4 BOOTC_IMAGE=quay.io/your/rag-bootc:latest bootc
```

The magic happens when you have a bootc enabled system running. If you do, and you'd like to update the operating system to the OS you just built
Expand Down
12 changes: 6 additions & 6 deletions recipes/natural_language_processing/rag/bootc/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ RUN mkdir /usr/etc-system && \
echo ${SSHPUBKEY} > /usr/etc-system/root.keys && chmod 0600 /usr/etc-system/root.keys

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 MODEL_IMAGE=quay.io/ai-lab/mistral-7b-instruct:latest
ARG APP_IMAGE=quay.io/ai-lab/${RECIPE}:latest
ARG SERVER_IMAGE=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
Expand All @@ -39,9 +39,9 @@ VOLUME /var/lib/containers
# Prepull the model, model_server & application images to populate the system.
# Comment the pull commands to keep bootc image smaller.
# The quadlet .image file added above pulls following images with service startup
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 ${SERVER_IMAGE}
RUN podman pull --root /usr/lib/containers/storage ${APP_IMAGE}
RUN podman pull --root /usr/lib/containers/storage ${MODEL_IMAGE}
RUN podman pull --root /usr/lib/containers/storage ${CHROMADBImage}

RUN podman system reset --force 2>/dev/null
6 changes: 3 additions & 3 deletions recipes/natural_language_processing/rag/quadlet/rag.image
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
WantedBy=rag.service

[Image]
Image=APPIMAGE
Image=MODELIMAGE
Image=SERVERIMAGE
Image=APP_IMAGE
Image=MODEL_IMAGE
Image=SERVER_IMAGE
8 changes: 4 additions & 4 deletions recipes/natural_language_processing/rag/quadlet/rag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ metadata:
spec:
initContainers:
- name: model-file
image: MODELIMAGE
image: MODEL_IMAGE
command: ['/usr/bin/install', "/model/model.file", "/shared/"]
volumeMounts:
- name: model-file
Expand All @@ -16,7 +16,7 @@ spec:
- env:
- name: MODEL_SERVICE_ENDPOINT
value: http://0.0.0.0:8001/v1
image: APPIMAGE
image: APP_IMAGE
name: rag-inference
ports:
- containerPort: 8501
Expand All @@ -26,7 +26,7 @@ spec:
- env:
- name: CHROMADB_ENDPOINT
value: http://0.0.0.0:800O/v1
image: CHROMADBIMAGE
image: CHROMADB_IMAGE
name: rag-chromadb
ports:
- containerPort: 8000
Expand All @@ -40,7 +40,7 @@ spec:
value: 8001
- name: MODEL_PATH
value: /model/model.file
image: SERVERIMAGE
image: SERVER_IMAGE
name: rag-model-service
ports:
- containerPort: 8001
Expand Down
6 changes: 3 additions & 3 deletions recipes/natural_language_processing/summarizer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Now that the Model Service is running we want to build and deploy our AI Applica

```bash
cd summarizer
make APPIMAGE=summarizer build
make APP_IMAGE=summarizer build
```

### Deploy the AI Application
Expand All @@ -126,7 +126,7 @@ To build a bootable container image that includes this sample summarizer workloa
and run:

```
make BOOTCIMAGE=quay.io/your/summarizer-bootc:latest bootc
make BOOTC_IMAGE=quay.io/your/summarizer-bootc:latest bootc
```

You can easily swap out the bootc/Containerfile FROM option with the following make command:
Expand All @@ -135,7 +135,7 @@ You can easily swap out the bootc/Containerfile FROM option with the following m
Substituting the bootc/Containerfile FROM command is simple using the Makefile FROM option.
```
make FROM=registry.redhat.io/rhel9-beta/rhel-bootc:9.4 BOOTCIMAGE=quay.io/your/summarizer-bootc:latest bootc
make FROM=registry.redhat.io/rhel9-beta/rhel-bootc:9.4 BOOTC_IMAGE=quay.io/your/summarizer-bootc:latest bootc
```
The magic happens when you have a bootc enabled system running. If you do, and you'd like to update the operating system to the OS you just built
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ RUN mkdir /usr/etc-system && \
echo ${SSHPUBKEY} > /usr/etc-system/root.keys && chmod 0600 /usr/etc-system/root.keys

ARG RECIPE=summarizer
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 MODEL_IMAGE=quay.io/ai-lab/mistral-7b-instruct:latest
ARG APP_IMAGE=quay.io/ai-lab/${RECIPE}:latest
ARG SERVER_IMAGE=quay.io/ai-lab/llamacpp-python:latest

# Add quadlet files to setup system to automatically run AI application on boot
COPY build/${RECIPE}.kube build/${RECIPE}.yaml /usr/share/containers/systemd
Expand All @@ -37,8 +37,8 @@ VOLUME /var/lib/containers
# Prepull the model, model_server & application images to populate the system.
# Comment the pull commands to keep bootc image smaller.
# The quadlet .image file added above pulls following images with service startup
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 ${SERVER_IMAGE}
RUN podman pull --root /usr/lib/containers/storage ${APP_IMAGE}
RUN podman pull --root /usr/lib/containers/storage ${MODEL_IMAGE}

RUN podman system reset --force 2>/dev/null
Loading

0 comments on commit 056c2db

Please sign in to comment.