-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathContainerfile
More file actions
97 lines (73 loc) · 3.06 KB
/
Containerfile
File metadata and controls
97 lines (73 loc) · 3.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# Build arguments declared in the global scope.
ARG ANSIBLE_CHATBOT_VERSION=latest
ARG IMAGE_TAGS=image-tags-not-defined
ARG GIT_COMMIT=git-commit-not-defined
# ======================================================
# Transient image to construct Python venv
# ------------------------------------------------------
FROM quay.io/lightspeed-core/lightspeed-stack:0.4.2 AS builder
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 pyproject.toml uv.lock LICENSE.md README.md ./
# generate requirements.txt file for dependencies packages from ansible-chatbot-stack
RUN uv export --no-hashes --no-header --no-annotate --no-dev --format requirements.txt > requirements.txt
RUN uv pip install -r requirements.txt
# ======================================================
# ======================================================
# Final image without uv package manager and based on lightspeed-stack base image
# ------------------------------------------------------
FROM registry.access.redhat.com/ubi9/python-312-minimal
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/
ENV LLAMA_STACK_CONFIG_DIR=/.llama/data
# Data and configuration
RUN mkdir -p /.llama/distributions/ansible-chatbot
RUN mkdir -p /.llama/data/distributions/ansible-chatbot
RUN echo -e "\
{\n\
\"version\": \"${ANSIBLE_CHATBOT_VERSION}\", \n\
\"imageTags\": \"${IMAGE_TAGS}\", \n\
\"gitCommit\": \"${GIT_COMMIT}\" \n\
}\n\
" > /.llama/distributions/ansible-chatbot/ansible-chatbot-version-info.json
ADD llama-stack/providers.d /.llama/providers.d
# Bootstrap
ADD entrypoint.sh /.llama
RUN chmod -R g+rw /.llama
RUN chmod +x /.llama/entrypoint.sh
RUN chown -R 1001:1001 /.llama
USER 1001
# Add executables from .venv to system PATH
ENV PATH="/app-root/.venv/bin:$PATH"
ENV PYTHON="/app-root/.venv/bin/python3.12"
# Disable OpenTelemetry explicitly
ENV OTEL_SDK_DISABLED=true
LABEL vendor="Red Hat, Inc."
ENTRYPOINT ["/app-root/.venv/bin/dumb-init", "--"]
CMD ["sh", "-c", "/.llama/entrypoint.sh $PYTHON"]
# ======================================================