Skip to content

Commit

Permalink
Merge pull request containers#169 from sallyom/update-make-bootc
Browse files Browse the repository at this point in the history
update make bootc for chatbot, summarizer
  • Loading branch information
sallyom authored Apr 5, 2024
2 parents 07771b5 + 65b66eb commit 2122947
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 60 deletions.
2 changes: 1 addition & 1 deletion recipes/natural_language_processing/chatbot/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build:
podman build -f builds/Containerfile -t ${APPIMAGE} .

.PHONY: bootc
bootc:
bootc: quadlet
podman build --cap-add SYS_ADMIN --build-arg "SSHPUBKEY=$(SSHPUBKEY)" -f bootc/Containerfile -t ${BOOTCIMAGE} .

.PHONY: quadlet
Expand Down
33 changes: 10 additions & 23 deletions recipes/natural_language_processing/chatbot/bootc/Containerfile
Original file line number Diff line number Diff line change
@@ -1,45 +1,30 @@
# Example: an AI powered sample application is embedded as a systemd service
# via Podman quadlet files in /usr/share/containers/systemd
#
# Use build command:
# podman build --build-arg "sshpubkey=$(cat $HOME/.ssh/id_rsa.pub)" -t quay.io/exampleos/myos .
# The --build-arg "SSHPUBKEY=$(cat ~/.ssh/id_rsa.pub)" option inserts your
# public key into the image, allowing root access via ssh.
# from recipes/natural_language_processing/chatbot, run
# 'make bootc'

FROM quay.io/centos-bootc/centos-bootc:stream9
ARG SSHPUBKEY

# The --build-arg "SSHPUBKEY=$(cat ~/.ssh/id_rsa.pub)" option inserts your
# public key into the image, allowing root access via ssh.
RUN mkdir /usr/etc-system && \
echo 'AuthorizedKeysFile /usr/etc-system/%u.keys' >> /etc/ssh/sshd_config.d/30-auth-system.conf && \
echo ${SSHPUBKEY} > /usr/etc-system/root.keys && chmod 0600 /usr/etc-system/root.keys

# pre-pull workload images:
# Comment the pull commands to keep bootc image smaller.
# The quadlet .image file added above pulls following images on boot if not
# pre-pulled here

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

# Add quadlet files to setup system to automatically run AI application on boot
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}.yaml
COPY build/${RECIPE}.kube build/${RECIPE}.yaml /usr/share/containers/systemd

# 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
# If commenting out the pulls below, uncomment this to track the images
# so the systemd service will wait for the images with the service startup
# COPY build/${RECIPE}.image /usr/share/containers/systemd

# Setup /usr/lib/containers/storage as an additional store for images.
# Remove once the base images have this set by default.
Expand All @@ -50,6 +35,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.
# 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}
Expand Down
8 changes: 4 additions & 4 deletions recipes/natural_language_processing/rag/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ bootc: quadlet
.PHONY: quadlet
quadlet:
# Modify quadlet files to match the server, model and app image
mkdir -p bootc/build
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 \
> bootc/build/${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 \
> bootc/build/${APP}.yaml
cp quadlet/${APP}.kube bootc/build/${APP}.kube
> build/${APP}.yaml
cp quadlet/${APP}.kube build/${APP}.kube

.PHONY: install
install:
Expand Down
17 changes: 9 additions & 8 deletions recipes/natural_language_processing/rag/bootc/Containerfile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Example: an AI powered sample application is embedded as a systemd service
# via Podman quadlet files in /usr/share/containers/systemd
#
# Use build command:
# podman build --build-arg "sshpubkey=$(cat $HOME/.ssh/id_rsa.pub)" -t quay.io/exampleos/myos .
# The --build-arg "SSHPUBKEY=$(cat ~/.ssh/id_rsa.pub)" option inserts your
# public key into the image, allowing root access via ssh.
# from recipes/natural_language_processing/rag, run
# 'make bootc'

FROM quay.io/centos-bootc/centos-bootc:stream9

ARG SSHPUBKEY

# The --build-arg "SSHPUBKEY=$(cat ~/.ssh/id_rsa.pub)" option inserts your
# public key into the image, allowing root access via ssh.
RUN mkdir /usr/etc-system && \
echo 'AuthorizedKeysFile /usr/etc-system/%u.keys' >> /etc/ssh/sshd_config.d/30-auth-system.conf && \
echo ${SSHPUBKEY} > /usr/etc-system/root.keys && chmod 0600 /usr/etc-system/root.keys
Expand All @@ -21,9 +21,11 @@ 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 bootc/build/${RECIPE}.kube bootc/build/${RECIPE}.yaml /usr/share/containers/systemd
COPY build/${RECIPE}.kube build/${RECIPE}.yaml /usr/share/containers/systemd

# Because images are prepulled, no need for .image quadlet
# If commenting out the pulls below, uncomment this to track the images
# so the systemd service will wait for the images with the service startup
# COPY build/${RECIPE}.image /usr/share/containers/systemd

# Setup /usr/lib/containers/storage as an additional store for images.
Expand All @@ -35,9 +37,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.
# Comment the pull commands and uncomment the .image file COPY to keep bootc image smaller.
# The quadlet .image file added above pulls following images on boot if not
# pre-pulled here
# 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}
Expand Down
2 changes: 1 addition & 1 deletion recipes/natural_language_processing/summarizer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ build:
podman build -f builds/Containerfile -t ${APPIMAGE} .

.PHONY: bootc
bootc:
bootc: quadlet
podman build --cap-add SYS_ADMIN --build-arg "SSHPUBKEY=$(SSHPUBKEY)" -f bootc/Containerfile -t ${BOOTCIMAGE} .

.PHONY: quadlet
Expand Down
33 changes: 10 additions & 23 deletions recipes/natural_language_processing/summarizer/bootc/Containerfile
Original file line number Diff line number Diff line change
@@ -1,45 +1,30 @@
# Example: an AI powered sample application is embedded as a systemd service
# via Podman quadlet files in /usr/share/containers/systemd
#
# Use build command:
# podman build --build-arg "sshpubkey=$(cat $HOME/.ssh/id_rsa.pub)" -t quay.io/exampleos/myos .
# The --build-arg "SSHPUBKEY=$(cat ~/.ssh/id_rsa.pub)" option inserts your
# public key into the image, allowing root access via ssh.
# from recipes/natural_language_processing/summarizer, run
# 'make bootc'

FROM quay.io/centos-bootc/centos-bootc:stream9
ARG SSHPUBKEY

# The --build-arg "SSHPUBKEY=$(cat ~/.ssh/id_rsa.pub)" option inserts your
# public key into the image, allowing root access via ssh.
RUN mkdir /usr/etc-system && \
echo 'AuthorizedKeysFile /usr/etc-system/%u.keys' >> /etc/ssh/sshd_config.d/30-auth-system.conf && \
echo ${SSHPUBKEY} > /usr/etc-system/root.keys && chmod 0600 /usr/etc-system/root.keys

# pre-pull workload images:
# Comment the pull commands to keep bootc image smaller.
# The quadlet .image file added above pulls following images on boot if not
# pre-pulled here

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

# Add quadlet files to setup system to automatically run AI application on boot
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}.yaml
COPY build/${RECIPE}.kube build/${RECIPE}.yaml /usr/share/containers/systemd

# 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
# If commenting out the pulls below, uncomment this to track the images
# so the systemd service will wait for the images with the service startup
# COPY build/${RECIPE}.image /usr/share/containers/systemd

# Setup /usr/lib/containers/storage as an additional store for images.
# Remove once the base images have this set by default.
Expand All @@ -50,6 +35,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.
# 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}
Expand Down

0 comments on commit 2122947

Please sign in to comment.