-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
49 lines (37 loc) · 962 Bytes
/
Dockerfile
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
FROM python:3.10-alpine as stage0
ENV PYTHONUNBUFFERED 1
RUN --mount=type=cache,target=/var/cache/apk \
apk add --virtual .build-deps \
gcc \
make \
python3-dev \
musl-dev \
postgresql-dev \
&& pip install -U pip \
&& apk add --no-cache libpq shadow
FROM stage0 as build
ARG requirements
RUN mkdir /requirements
WORKDIR /requirements
COPY requirements/${requirements} /requirements/
RUN --mount=type=cache,target=/root/.cache \
printf -- '-r\0%s\0' *.txt | xargs -0 pip install
RUN apk del --no-cache .build-deps
FROM python:3.10-alpine
ARG docker_uid
ARG docker_gid
ENV PYTHONUNBUFFERED 1
COPY --from=build etc /etc
COPY --from=build lib /lib
COPY --from=build usr /usr
RUN adduser \
--disabled-password \
--gecos '' \
-u ${docker_uid} \
python \
&& groupmod -g ${docker_gid} python \
&& mkdir /src \
&& mkdir -p /srv/media /srv/static \
&& chown -R python:python /srv /home/python
WORKDIR /src
USER python