Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing passing port as a build argument to containers #258

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion model_servers/common/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ endif

.PHONY: build
build:
podman build --squash-all --build-arg $(PORT) -t $(IMAGE) . -f base/Containerfile
podman build --squash-all --build-arg PORT=$(PORT) -t $(IMAGE) . -f base/Containerfile
Gregory-Pereira marked this conversation as resolved.
Show resolved Hide resolved

.PHONY: install
install:
Expand Down
3 changes: 2 additions & 1 deletion model_servers/llamacpp_python/base/Containerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
FROM registry.access.redhat.com/ubi9/python-311:1-52
ARG PORT=8001
WORKDIR /locallm
COPY src .
RUN pip install --no-cache-dir --verbose -r ./requirements.txt
EXPOSE 8001
EXPOSE $PORT
ENTRYPOINT [ "sh", "./run.sh" ]
2 changes: 2 additions & 0 deletions model_servers/llamacpp_python/cuda/Containerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
FROM quay.io/opendatahub/workbench-images:cuda-ubi9-python-3.9-20231206
ARG PORT=8001
WORKDIR /locallm
COPY src .
RUN pip install --upgrade pip
ENV CMAKE_ARGS="-DLLAMA_CUBLAS=on"
ENV FORCE_CMAKE=1
RUN pip install --no-cache-dir --upgrade -r /locallm/requirements.txt
EXPOSE $PORT
ENTRYPOINT [ "sh", "run.sh" ]
2 changes: 2 additions & 0 deletions model_servers/llamacpp_python/vulkan/Containerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM registry.access.redhat.com/ubi9/python-311:1-52
USER 0
ARG PORT=8001
RUN dnf install -y python3-dnf-plugin-versionlock && \
dnf copr enable -y slp/mesa-krunkit epel-9-aarch64 && \
dnf install -y mesa-vulkan-drivers-23.3.3-101.el9.aarch64 && \
Expand All @@ -12,4 +13,5 @@ RUN pip install --upgrade pip
ENV CMAKE_ARGS="-DLLAMA_VULKAN=on"
ENV FORCE_CMAKE=1
RUN pip install --no-cache-dir --upgrade -r /locallm/requirements.txt
EXPOSE $PORT
ENTRYPOINT [ "sh", "run.sh" ]
3 changes: 2 additions & 1 deletion model_servers/whispercpp/base/Containerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
FROM registry.access.redhat.com/ubi9/ubi:latest as builder

ARG PORT=8001
WORKDIR /app
RUN dnf install -y git make gcc gcc-c++
RUN mkdir whisper && cd whisper && git clone https://github.com/ggerganov/whisper.cpp.git . && \
Expand All @@ -21,4 +21,5 @@ COPY --from=mwader/static-ffmpeg:6.1.1 /ffprobe /bin/

COPY src /app/
ENV AUDIO_FILE=/app/jfk.wav
EXPOSE $PORT
ENTRYPOINT ["sh", "run.sh"]
3 changes: 2 additions & 1 deletion recipes/audio/audio_to_text/app/Containerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM registry.access.redhat.com/ubi9/python-311:1-52
ARG PORT=8501
WORKDIR /locallm
COPY requirements.txt /locallm/requirements.txt
RUN pip install --upgrade pip && \
pip install --no-cache-dir --upgrade -r requirements.txt
COPY whisper_client.py whisper_client.py
EXPOSE 8501
EXPOSE $PORT
ENTRYPOINT [ "streamlit", "run", "whisper_client.py" ]
5 changes: 3 additions & 2 deletions recipes/common/Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ install::

.PHONY: build
build:
podman build --squash-all $${ARCH:+--arch $${ARCH}} $${FROM:+--from $${FROM}} -t ${APP_IMAGE} app/
podman build --squash-all $${ARCH:+--arch $${ARCH}} $${FROM:+--from $${FROM}} --build-arg PORT=$(PORT) -t ${APP_IMAGE} app/

.PHONY: bootc
bootc: quadlet
Expand All @@ -85,6 +85,7 @@ bootc: quadlet
$${AUTH_JSON:+-v $${AUTH_JSON}:/run/containers/0/auth.json} \
--security-opt label=disable \
--cap-add SYS_ADMIN \
$${PORT:+--build-arg PORT=$${PORT}} \
--build-arg MODEL_IMAGE=$(MODEL_IMAGE) \
--build-arg APP_IMAGE=$(APP_IMAGE) \
--build-arg SERVER_IMAGE=$(SERVER_IMAGE) \
Expand All @@ -101,7 +102,7 @@ bootc: quadlet

.PHONY: bootc-run
bootc-run:
podman run -d --rm --name $(APP)-bootc -p 8080:8501 --privileged \
podman run -d --rm --name $(APP)-bootc -p 8080:$(PORT) --privileged \
Gregory-Pereira marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ${PORT}:80 or something like that.

$${AUTH_JSON:+-v $${AUTH_JSON}:/run/containers/0/auth.json} \
$(BOOTC_IMAGE) /sbin/init

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM registry.access.redhat.com/ubi9/python-311:1-52
ARG PORT=8501
WORKDIR /locallm
COPY requirements.txt /locallm/requirements.txt
RUN pip install --upgrade pip && \
pip install --no-cache-dir --upgrade -r requirements.txt
COPY object_detection_client.py object_detection_client.py
EXPOSE 8501
EXPOSE $PORT
ENTRYPOINT [ "streamlit", "run", "object_detection_client.py" ]
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM registry.access.redhat.com/ubi9/python-311:1-52
ARG PORT=8000
WORKDIR /locallm
COPY requirements.txt /locallm/requirements.txt
RUN pip install --upgrade pip && \
pip install --no-cache-dir --upgrade -r requirements.txt
COPY object_detection_server.py object_detection_server.py
EXPOSE 8000
EXPOSE $PORT
ENTRYPOINT [ "uvicorn", "object_detection_server:app", "--host", "0.0.0.0" ]
3 changes: 2 additions & 1 deletion recipes/multimodal/image_understanding/app/Containerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM registry.access.redhat.com/ubi9/python-311:1-52
ARG PORT=8501
WORKDIR /image_understanding
COPY requirements.txt .
RUN pip install --upgrade pip && \
pip install --no-cache-dir --upgrade -r requirements.txt
COPY image_understanding.py .
EXPOSE 8501
EXPOSE $PORT
ENTRYPOINT [ "streamlit", "run", "image_understanding.py" ]
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM registry.access.redhat.com/ubi9/python-311:1-52
ARG PORT=8501
WORKDIR /chat
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir --upgrade -r /chat/requirements.txt
COPY chatbot_ui.py .
EXPOSE 8501
EXPOSE $PORT
ENTRYPOINT [ "streamlit", "run", "chatbot_ui.py" ]
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

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

# The --build-arg "SSHPUBKEY=$(cat ~/.ssh/id_rsa.pub)" option inserts your
# public key into the image, allowing root access via ssh.
Expand Down Expand Up @@ -41,4 +42,6 @@ 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}

EXPOSE $PORT

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

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

# The --build-arg "SSHPUBKEY=$(cat ~/.ssh/id_rsa.pub)" option inserts your
# public key into the image, allowing root access via ssh.
Expand All @@ -18,5 +19,7 @@ ARG RECIPE=chatbot
# Add quadlet files to setup system to automatically run AI application on boot
COPY build/${RECIPE}.image build/${RECIPE}.kube build/${RECIPE}.yaml /usr/share/containers/systemd

EXPOSE $PORT

# Added for running as an OCI Container to prevent Overlay on Overlay issues.
VOLUME /var/lib/containers
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM registry.access.redhat.com/ubi9/python-311:1-52
ARG PORT=8501
WORKDIR /codegen
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir --upgrade -r /codegen/requirements.txt
COPY codegen-app.py .
EXPOSE 8501
EXPOSE $PORT
ENTRYPOINT ["streamlit", "run", "codegen-app.py"]
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

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

RUN set -eu; mkdir -p /usr/ssh && \
echo 'AuthorizedKeysFile /usr/ssh/%u.keys .ssh/authorized_keys .ssh/authorized_keys2' >> /etc/ssh/sshd_config.d/30-auth-system.conf && \
Expand Down Expand Up @@ -42,4 +43,6 @@ 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}

EXPOSE $PORT

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

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

# The --build-arg "SSHPUBKEY=$(cat ~/.ssh/id_rsa.pub)" option inserts your
# public key into the image, allowing root access via ssh.
Expand All @@ -18,5 +19,7 @@ ARG RECIPE=codegen
# Add quadlet files to setup system to automatically run AI application on boot
COPY build/${RECIPE}.image build/${RECIPE}.kube build/${RECIPE}.yaml /usr/share/containers/systemd

EXPOSE $PORT

# Added for running as an OCI Container to prevent Overlay on Overlay issues.
VOLUME /var/lib/containers
3 changes: 2 additions & 1 deletion recipes/natural_language_processing/rag/app/Containerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM registry.access.redhat.com/ubi9/python-311:1-52
ARG PORT=8501
### Update sqlite for chroma
USER root
RUN dnf remove sqlite3 -y
Expand All @@ -16,6 +17,6 @@ COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir --upgrade -r /rag/requirements.txt
COPY rag_app.py .
EXPOSE 8501
EXPOSE $PORT
ENV HF_HUB_CACHE=/rag/models/
ENTRYPOINT [ "streamlit", "run" ,"rag_app.py" ]
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# 'make bootc'

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

ARG SSHPUBKEY
ARG PORT=8501

# The --build-arg "SSHPUBKEY=$(cat ~/.ssh/id_rsa.pub)" option inserts your
# public key into the image, allowing root access via ssh.
Expand Down Expand Up @@ -44,4 +44,6 @@ 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}

EXPOSE $PORT

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

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

# The --build-arg "SSHPUBKEY=$(cat ~/.ssh/id_rsa.pub)" option inserts your
# public key into the image, allowing root access via ssh.
Expand All @@ -18,5 +19,7 @@ ARG RECIPE=rag
# Add quadlet files to setup system to automatically run AI application on boot
COPY build/${RECIPE}.image build/${RECIPE}.kube build/${RECIPE}.yaml /usr/share/containers/systemd

EXPOSE $PORT

# Added for running as an OCI Container to prevent Overlay on Overlay issues.
VOLUME /var/lib/containers
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM registry.access.redhat.com/ubi9/python-311:1-52
ARG PORT=8501
WORKDIR /summarizer
COPY requirements.txt .
RUN pip install --upgrade pip
RUN pip install --no-cache-dir --upgrade -r /summarizer/requirements.txt
COPY summarizer.py .
EXPOSE 8501
EXPOSE $PORT
ENTRYPOINT [ "streamlit", "run", "summarizer.py" ]
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

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

# The --build-arg "SSHPUBKEY=$(cat ~/.ssh/id_rsa.pub)" option inserts your
# public key into the image, allowing root access via ssh.
Expand Down Expand Up @@ -41,4 +42,6 @@ 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}

EXPOSE $PORT

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

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

# The --build-arg "SSHPUBKEY=$(cat ~/.ssh/id_rsa.pub)" option inserts your
# public key into the image, allowing root access via ssh.
Expand All @@ -18,5 +19,7 @@ ARG RECIPE=summarizer
# Add quadlet files to setup system to automatically run AI application on boot
COPY build/${RECIPE}.image build/${RECIPE}.kube build/${RECIPE}.yaml /usr/share/containers/systemd

EXPOSE $PORT

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