Skip to content
Open
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
58 changes: 22 additions & 36 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,42 @@ ARG IMAGE_TAGS=image-tags-not-defined
ARG GIT_COMMIT=git-commit-not-defined

# ======================================================
# Transient image to construct Python venv
# Base-image with all dependencies for Python venv
# Lightspeed-stack bundles all required dependencies
# For running llama-stack in library mode.
#
# To include more dependencies, create upstream PR
# to update this file:
# https://github.com/lightspeed-core/lightspeed-stack/blob/main/pyproject.toml
# ------------------------------------------------------
FROM quay.io/lightspeed-core/lightspeed-stack:0.1.3 AS builder
FROM quay.io/lightspeed-core/lightspeed-stack:0.2.0

ARG APP_ROOT=/app-root
WORKDIR /app-root

# UV_PYTHON_DOWNLOADS=0 : Disable Python interpreter downloads and use the system interpreter.
ENV UV_COMPILE_BYTECODE=0 \
UV_LINK_MODE=copy \
UV_PYTHON_DOWNLOADS=0

# Install uv package manager
RUN pip3.12 install uv

# Add explicit files and directories
# (avoid accidental inclusion of local directories or env files or credentials)
COPY requirements.txt LICENSE.md README.md ./

RUN uv pip install -r requirements.txt
# ======================================================
COPY pyproject.toml LICENSE.md README.md ./

# ======================================================
# Final image without uv package manager and based on lightspeed-stack base image
# ------------------------------------------------------
FROM registry.access.redhat.com/ubi9/python-312-minimal
# Add only project-specific dependencies without adding other dependencies
# to not break the dependencies of the base image.
ENV UV_COMPILE_BYTECODE=0 \
UV_LINK_MODE=copy \
UV_PYTHON_DOWNLOADS=0 \
UV_NO_CACHE=1
# Install top-level dependencies from pyproject.toml
# List of dependencies is first parsed from pyproject.toml
RUN python -c "import tomllib, sys; print(' '.join(tomllib.load(open('pyproject.toml','rb'))['project']['dependencies']))" \
| xargs uv pip install --no-deps
# Install the project itself
RUN uv pip install . --no-deps && uv clean

USER 0

# Re-declaring arguments without a value, inherits the global default one.
ARG APP_ROOT
ARG ANSIBLE_CHATBOT_VERSION
ARG IMAGE_TAGS
ARG GIT_COMMIT
RUN microdnf install -y --nodocs --setopt=keepcache=0 --setopt=tsflags=nodocs jq

# PYTHONDONTWRITEBYTECODE 1 : disable the generation of .pyc
# PYTHONUNBUFFERED 1 : force the stdout and stderr streams to be unbuffered
# PYTHONCOERCECLOCALE 0, PYTHONUTF8 1 : skip legacy locales and use UTF-8 mode
ENV PYTHONDONTWRITEBYTECODE=1 \
PYTHONUNBUFFERED=1 \
PYTHONCOERCECLOCALE=0 \
PYTHONUTF8=1 \
PYTHONIOENCODING=UTF-8 \
LANG=en_US.UTF-8

COPY --from=builder --chown=1001:1001 /app-root /app-root

# this directory is checked by ecosystem-cert-preflight-checks task in Konflux
COPY --from=builder /app-root/LICENSE.md /licenses/
COPY LICENSE.md /licenses/

ENV LLAMA_STACK_CONFIG_DIR=/.llama/data

Expand Down
3 changes: 0 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,6 @@ check-env-build:
exit 1; \
fi

requirements.txt:
uv export --no-hashes --no-header --no-annotate --no-dev --format requirements.txt > requirements.txt

build: check-env-build setup requirements.txt
@echo "Building customized Ansible Chatbot Stack image from lightspeed-core/lightspeed-stack..."
$(CONTAINER_RUNTIME) build --no-cache --platform $(PLATFORM) -f ./Containerfile \
Expand Down
12 changes: 0 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,9 @@ description = "Ansible Lightspeed Intelligent Assistant (ALIA)"
readme = "README.md"
requires-python = ">=3.12"
dependencies = [
"aiosqlite~=0.21.0",
"faiss-cpu~=1.11",
"fire~=0.7.0",
"lightspeed-stack-providers==0.1.15",
"mcp~=1.9.4",
"numpy==2.2.6",
"opentelemetry-api~=1.34.1",
"opentelemetry-exporter-otlp~=1.34.1",
"sentence-transformers>=5.0.0",
"sqlalchemy~=2.0.41",
"litellm~=1.75.3",
]

[dependency-groups]
dev = [
"cachetools>=6.1.0",
"kubernetes>=33.1.0",
]
Loading