Skip to content

Commit 873f3ac

Browse files
committed
Build psutil in a build stage
1 parent 788dd8a commit 873f3ac

File tree

1 file changed

+34
-2
lines changed

1 file changed

+34
-2
lines changed

images/singleuser-sample/Dockerfile

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
# The build stage
2+
# ---------------
3+
FROM python:3.9-bullseye as build-stage
4+
5+
# VULN_SCAN_TIME=2022-08-08_05:22:22
6+
7+
WORKDIR /build-stage
8+
9+
# Build wheels for packages that require gcc or other build dependencies and
10+
# lack wheels either for amd64 or aarch64.
11+
#
12+
# - https://pypi.org/project/psutil/#files, no wheels available as of 5.9.1
13+
# for aarch64. See https://github.com/giampaolo/psutil/pull/2070.
14+
#
15+
# If you find a dependency here no longer listed in requirements.txt, remove it
16+
# from here as well. The more wheels we build here and copy and then install,
17+
# where the copy and install are separate steps, the larger the final image
18+
# becomes.
19+
#
20+
COPY requirements.txt requirements.txt
21+
RUN pip install build \
22+
&& pip wheel \
23+
$(cat requirements.txt | grep "psutil==")
24+
25+
26+
# The final stage
27+
# ---------------
28+
129
FROM python:3.9-slim-bullseye
230

331
# VULN_SCAN_TIME=
@@ -19,13 +47,17 @@ RUN apt-get update \
1947
&& apt-get install -y --no-install-recommends \
2048
ca-certificates \
2149
dnsutils \
22-
git \
2350
iputils-ping \
2451
tini \
52+
# requirement for nbgitpuller
53+
git \
2554
&& rm -rf /var/lib/apt/lists/*
2655

56+
COPY --from=build-stage /build-stage/*.whl /tmp/pre-built-wheels/
2757
COPY requirements.txt /tmp/requirements.txt
28-
RUN pip install --no-cache-dir -r /tmp/requirements.txt
58+
RUN pip install --no-cache-dir \
59+
/tmp/pre-built-wheels/*.whl \
60+
-r /tmp/requirements.txt
2961

3062
WORKDIR ${HOME}
3163
USER ${NB_USER}

0 commit comments

Comments
 (0)