deployment stuff
[redakcja.git] / Dockerfile
1 FROM python:3.10-slim-trixie AS base
2
3 ARG UID=8200
4 ARG GID=8200
5
6 COPY requirements/requirements.txt requirements.txt
7
8 RUN --mount=type=cache,target=/root/.cache/pip \
9     pip install -r requirements.txt
10
11 RUN addgroup --gid $GID app && \
12     adduser --gid $GID --home /app --uid $UID app
13
14 USER app
15
16 WORKDIR /app/src
17
18
19
20
21 FROM base AS dev
22
23 USER root
24 RUN --mount=type=cache,target=/root/.cache/pip \
25     pip install --no-cache-dir coverage
26 USER app
27
28
29
30
31 FROM base AS prod-base
32
33 USER root
34
35 RUN --mount=type=cache,target=/root/.cache/pip \
36     pip install --no-cache-dir gunicorn
37
38 USER app
39
40 COPY src /app/src
41
42
43
44 FROM prod-base AS static-builder
45
46 RUN python manage.py collectstatic --noinput
47
48
49 FROM nginx:alpine AS nginx
50
51 ARG UID=8200
52 ARG GID=8200
53
54 # COPY nginx.conf conf.d/...
55
56 RUN addgroup -g $GID app && addgroup nginx app
57 COPY --from=static-builder /app/src/static /app/var/static
58
59
60
61
62 FROM prod-base AS prod
63
64 COPY --from=static-builder /app/src/static/staticfiles.json /app/src/static/staticfiles.json