Skip to content

Commit 590130e

Browse files
committed
Move to two stage docker build for the operator
1 parent e7820f0 commit 590130e

File tree

1 file changed

+34
-9
lines changed

1 file changed

+34
-9
lines changed

python/Dockerfile

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,34 @@
1-
FROM python:3.9
1+
FROM ubuntu:jammy as build-image
2+
3+
RUN apt-get update && \
4+
apt-get upgrade -y && \
5+
apt-get install --no-install-recommends python3.10-venv git -y && \
6+
rm -rf /var/lib/apt/lists/*
7+
8+
# build into a venv we can copy across
9+
RUN python3 -m venv /opt/venv
10+
ENV PATH="/opt/venv/bin:$PATH"
11+
12+
COPY ./requirements.txt /perftest/
13+
RUN pip install -U pip setuptools
14+
RUN pip install --no-deps --requirement /perftest/requirements.txt
15+
16+
COPY . /perftest
17+
RUN pip install -e /perftest
18+
19+
#
20+
# Now the image we run with
21+
#
22+
FROM ubuntu:jammy as run-image
23+
24+
RUN apt-get update && \
25+
apt-get upgrade -y && \
26+
apt-get install --no-install-recommends python3 tini ca-certificates -y && \
27+
rm -rf /var/lib/apt/lists/*
28+
29+
# Copy accross the venv
30+
COPY --from=build-image /opt/venv /opt/venv
31+
ENV PATH="/opt/venv/bin:$PATH"
232

333
# Create the user that will be used to run the app
434
ENV APP_UID 1001
@@ -22,14 +52,9 @@ RUN apt-get update && \
2252
# Don't buffer stdout and stderr as it breaks realtime logging
2353
ENV PYTHONUNBUFFERED 1
2454

25-
# Install dependencies
26-
# Doing this separately by copying only the requirements file enables better use of the build cache
27-
COPY ./requirements.txt /perftest/
28-
RUN pip install --no-deps --requirement /perftest/requirements.txt
29-
30-
# Install the perftest package
31-
COPY . /perftest
32-
RUN pip install --no-deps -e /perftest
55+
# Make httpx use the system trust roots
56+
# By default, this means we use the CAs from the ca-certificates package
57+
ENV SSL_CERT_FILE /etc/ssl/certs/ca-certificates.crt
3358

3459
# By default, run the operator using kopf
3560
USER $APP_UID

0 commit comments

Comments
 (0)