-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDockerfile.requirements
More file actions
58 lines (49 loc) · 1.91 KB
/
Copy pathDockerfile.requirements
File metadata and controls
58 lines (49 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# syntax=docker/dockerfile:1.3
# BUILD STAGE - Download dependencies
FROM python:3.12-alpine3.21 as build
RUN apk update \
&& apk upgrade --no-cache \
&& apk add --update --no-cache \
git \
openssh \
postgresql-dev \
musl-dev \
libxslt-dev \
python3-dev \
libffi-dev \
gcc \
libcurl \
bash \
rust \
build-base \
cargo \
curl-dev \
&& pip install --upgrade 'pip>=26.1.2' setuptools
COPY requirements.txt /
WORKDIR /pip-packages/
RUN pip wheel -r /requirements.txt
# RUNTIME STAGE - Copy packages from build stage and install runtime dependencies
FROM python:3.12-alpine3.21
RUN apk update && apk upgrade --no-cache \
&& apk add --no-cache postgresql-libs \
&& apk add --no-cache --virtual .build-deps \
gcc \
musl-dev \
postgresql-dev \
libxslt-dev \
python3-dev \
build-base \
libffi-dev \
openssl-dev \
make \
curl-dev \
libcurl
WORKDIR /pip-packages/
COPY --from=build /pip-packages/ /pip-packages/
RUN rm -rf /pip-packages/src \
&& pip install --no-deps --no-index --find-links=/pip-packages/ /pip-packages/* \
&& pip install --upgrade 'setuptools>=82' 'pip>=26.1.2' --break-system-packages \
&& rm -rf /usr/local/lib/python3.12/ensurepip/_bundled/pip-*.whl \
&& apk del .build-deps
# expat must be upgraded after .build-deps removal; see alpine#15709
RUN apk add --upgrade expat