Skip to content
Merged
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
75 changes: 75 additions & 0 deletions Dockerfile.konflux
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
FROM registry.access.redhat.com/ubi9/python-312:latest as build

USER 0
WORKDIR /app

ARG GUARDRAILS_PROFILE=opensource

COPY requirements.txt requirements-torch.txt pyproject.toml README.md ./
COPY nemoguardrails/ ./nemoguardrails/
COPY scripts/ ./scripts/
COPY examples/bots/ ./examples/bots/

RUN chmod +x ./scripts/entrypoint.sh

RUN python3 -m pip install --no-cache-dir pyyaml

RUN python3 ./scripts/filter_guardrails.py ./scripts/provider-list.yaml $GUARDRAILS_PROFILE

ENV HF_HOME=/app/.cache/huggingface \
TRANSFORMERS_CACHE=/app/.cache/transformers \
SENTENCE_TRANSFORMERS_HOME=/app/.cache/sentence_transformers \
NLTK_DATA=/app/.cache/nltk_data \
FASTEMBED_CACHE_PATH=/app/.cache/fastembed

RUN python3 -m venv /app/.venv && \
/app/.venv/bin/pip install --no-cache-dir -r requirements.txt && \
/app/.venv/bin/pip install --no-cache-dir --no-deps . && \
rm -rf /root/.cache/pip /tmp/* /var/tmp/*

RUN /app/.venv/bin/pip install --no-cache-dir /cachi2/output/deps/generic/en_core_web_lg-3.8.0-py3-none-any.whl

RUN /app/.venv/bin/pip install --no-cache-dir -r requirements-torch.txt

RUN set -ex && \
GUARDRAILS_PROFILE=$GUARDRAILS_PROFILE /app/.venv/bin/python ./scripts/pre_download_required_models.py && \
find /app/.cache -type f -name "*.pyc" -delete && \
find /app/.cache -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true && \
find /app/.cache -type d -name ".git" -exec rm -rf {} + 2>/dev/null || true && \
rm -rf /app/.cache/huggingface/xet /root/.cache /tmp/* /var/tmp/*

FROM registry.access.redhat.com/ubi9/python-312:latest as runtime

USER 0
WORKDIR /app

COPY --from=build /app /app

RUN rm -f /etc/security/namespace.conf /usr/lib64/security/pam_namespace.so || true && \
chgrp -R 0 /app && \
chmod -R g=u /app && \
chmod +x /app/scripts/entrypoint.sh

USER 1001

ENV HF_HOME=/app/.cache/huggingface \
TRANSFORMERS_CACHE=/app/.cache/transformers \
SENTENCE_TRANSFORMERS_HOME=/app/.cache/sentence_transformers \
NLTK_DATA=/app/.cache/nltk_data \
FASTEMBED_CACHE_PATH=/app/.cache/fastembed \
PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1

EXPOSE 8000
ENTRYPOINT ["./scripts/entrypoint.sh"]

LABEL com.redhat.component="odh-nemo-guardrails" \
name="rhoai/odh-nemo-guardrails-rhel9" \
description="NeMo Guardrails is an open-source toolkit for easily adding programmable guardrails to LLM-based conversational systems" \
summary="odh-nemo-guardrails" \
maintainer="['[email protected]']" \
io.openshift.expose-services="8000:http" \
io.k8s.display-name="odh-nemo-guardrails" \
io.k8s.description="NeMo Guardrails toolkit for controlling and securing LLM-based conversational systems" \
com.redhat.license_terms="https://www.redhat.com/licenses/Red_Hat_Standard_EULA_20191108.pdf"
7 changes: 7 additions & 0 deletions artifacts.lock.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
metadata:
version: "1.0"
artifacts:
- download_url: "https://github.com/explosion/spacy-models/releases/download/en_core_web_lg-3.8.0/en_core_web_lg-3.8.0-py3-none-any.whl"
checksum: "sha256:293e9547a655b25499198ab15a525b05b9407a75f10255e405e8c3854329ab63"
filename: "en_core_web_lg-3.8.0-py3-none-any.whl"
2 changes: 2 additions & 0 deletions requirements-torch.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--index-url https://download.pytorch.org/whl/cpu
torch==2.9.0
29 changes: 29 additions & 0 deletions requirements-torch.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# This file is autogenerated by pip-compile with Python 3.12
# by the following command:
#
# pip-compile requirements-torch.in
#
--index-url https://download.pytorch.org/whl/cpu

filelock==3.20.0
# via torch
fsspec==2025.12.0
# via torch
jinja2==3.1.6
# via torch
markupsafe==2.1.5
# via jinja2
mpmath==1.3.0
# via sympy
networkx==3.6.1
# via torch
sympy==1.14.0
# via torch
torch==2.9.0+cpu
# via -r requirements-torch.in
typing-extensions==4.15.0
# via torch

# The following packages are considered to be unsafe in a requirements file:
# setuptools
Loading