til.duyet.net
Search…
"Distroless" Docker Images
"Distroless" images contain only your application and its runtime dependencies. They do not contain package managers, shells or any other programs you would expect to find in a standard Linux distribution.
1
# Build a virtualenv using the appropriate Debian release
2
# * Install python3-venv for the built-in Python3 venv module (not installed by default)
3
# * Install gcc libpython3-dev to compile C Python modules
4
# * Update pip to support bdist_wheel
5
FROM debian:buster-slim AS build
6
RUN apt-get update && \
7
apt-get install --no-install-suggests --no-install-recommends --yes python3-venv gcc libpython3-dev && \
8
python3 -m venv /venv && \
9
/venv/bin/pip install --upgrade pip
10
​
11
# Build the virtualenv as a separate step: Only re-execute this step when requirements.txt changes
12
FROM build AS build-venv
13
COPY requirements.txt /requirements.txt
14
RUN /venv/bin/pip install --disable-pip-version-check -r /requirements.txt
15
​
16
# Copy the virtualenv into a distroless image
17
FROM gcr.io/distroless/python3-debian10
18
COPY --from=build-venv /venv /venv
19
COPY . /app
20
WORKDIR /app
21
ENTRYPOINT ["/venv/bin/python3", "psutil_example.py"]
Copied!
Copy link
Edit on GitHub