Skip to content

Commit

Permalink
Make container image smaller (2)
Browse files Browse the repository at this point in the history
Installs pip system package only in the builder image which is not
included in the final image.
  • Loading branch information
hluk committed May 5, 2022
1 parent 18fde01 commit dce24fb
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
FROM registry.access.redhat.com/ubi8/ubi-minimal:8.5 as base

RUN microdnf install -y --nodocs --setopt install_weak_deps=0 \
python39 \
python39-pip \
&& microdnf clean -y all

ENV PYTHONFAULTHANDLER=1 \
PYTHONHASHSEED=random \
PYTHONUNBUFFERED=1 \
Expand All @@ -13,7 +8,10 @@ ENV PYTHONFAULTHANDLER=1 \
# --- Build stage
FROM base as builder

RUN microdnf install -y --nodocs --setopt install_weak_deps=0 git-core
RUN microdnf install -y --nodocs --setopt install_weak_deps=0 \
git-core \
python39 \
python39-pip

ENV PIP_DEFAULT_TIMEOUT=100 \
PIP_DISABLE_PIP_VERSION_CHECK=1 \
Expand Down Expand Up @@ -49,10 +47,10 @@ WORKDIR /src
COPY --from=builder /src .
COPY --from=builder /venv /venv
RUN set -ex \
&& microdnf install -y --nodocs --setopt install_weak_deps=0 python39 \
&& microdnf clean -y all \
&& /venv/bin/pip install --no-cache-dir dist/*.whl \
&& rm -r dist \
&& microdnf remove -y python39-pip \
&& microdnf clean -y all \
# This will allow a non-root user to install a custom root CA at run-time
&& chmod 777 /etc/pki/tls/certs/ca-bundle.crt

Expand Down

0 comments on commit dce24fb

Please sign in to comment.