Skip to content

Commit d69462b

Browse files
committed
feat(Dockerfiles): switch from s2i python images to plain ubi/cs9 ones
The main benefit is size and cve exposure, as the python images come with packages we don't use; python and pip is enough for us. Additionally, using plain ubi makes things more explicit.
1 parent c0c64e0 commit d69462b

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

base/ubi9-python-3.11/Dockerfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
1-
FROM registry.access.redhat.com/ubi9/python-311:latest
1+
FROM registry.access.redhat.com/ubi9/ubi:latest
2+
3+
# perform the setup that python s2i image used to do for us
4+
# but this way it uses a lot less disk space (hundreds of megabytes less)
5+
ENV VIRTUAL_ENV="/opt/app-root"
6+
ENV PATH="${VIRTUAL_ENV}/bin:${PATH}"
7+
RUN useradd --uid 1001 --gid 0 --create-home --base-dir / --home-dir /opt/app-root/src \
8+
--comment "Default Application User" --shell /bin/bash default && \
9+
dnf install -y python311-pip && dnf clean all && rm -rf /var/cache/yum/* && \
10+
python3.11 -m venv "${VIRTUAL_ENV}"
11+
12+
USER 1001
213

314
ARG SOURCE_CODE=base/ubi9-python-3.11
415

@@ -20,7 +31,7 @@ RUN pip install --no-cache-dir -U "micropipenv[toml]"
2031
# Install Python dependencies from Pipfile.lock file
2132
COPY ${SOURCE_CODE}/Pipfile.lock ./
2233

23-
RUN echo "Installing softwares and packages" && micropipenv install && rm -f ./Pipfile.lock
34+
RUN echo "Installing software and packages" && micropipenv install && rm -f ./Pipfile.lock
2435

2536
# OS Packages needs to be installed as root
2637
USER root

0 commit comments

Comments
 (0)