6b71bf2cad0d6e8077f602c549993396fd9583de
[redakcja.git] / Dockerfile
1 FROM python:3.10-slim-trixie AS base
2
3 ARG UID=8200
4 ARG GID=8200
5
6 RUN apt-get update \
7  && apt-get install -y --no-install-recommends \
8     imagemagick tesseract-ocr tesseract-ocr-pol curl \
9  && rm -rf /var/lib/apt/lists/*
10
11 # Install dart-sass for compiling SCSS.
12 ARG DART_SASS_VERSION=1.108.2
13 RUN arch=$(dpkg --print-architecture | sed 's/amd64/x64/') && \
14     curl -fsSL "https://github.com/sass/dart-sass/releases/download/${DART_SASS_VERSION}/dart-sass-${DART_SASS_VERSION}-linux-${arch}.tar.gz" \
15     | tar xz -C /opt
16
17 COPY requirements/requirements.txt requirements.txt
18
19 RUN --mount=type=cache,target=/root/.cache/pip \
20     pip install -r requirements.txt
21
22 RUN addgroup --gid $GID app && \
23     adduser --gid $GID --home /app --uid $UID app
24
25 USER app
26
27 WORKDIR /app/src
28
29
30
31
32 FROM base AS dev
33
34 USER root
35 RUN --mount=type=cache,target=/root/.cache/pip \
36     pip install --no-cache-dir coverage
37 USER app
38
39
40
41
42 FROM base AS prod-base
43
44 USER root
45
46 RUN --mount=type=cache,target=/root/.cache/pip \
47     pip install --no-cache-dir gunicorn
48
49 USER app
50
51 COPY src /app/src
52
53
54
55 FROM prod-base AS static-builder
56
57 RUN python manage.py collectstatic --noinput
58
59
60 FROM nginx:alpine AS nginx
61
62 ARG UID=8200
63 ARG GID=8200
64
65 COPY scripts/nginx.conf /etc/nginx/conf.d/default.conf
66
67 RUN addgroup -g $GID app && addgroup nginx app
68 COPY --from=static-builder /app/var/static /app/var/static
69
70
71
72
73 FROM prod-base AS prod
74
75 COPY --from=static-builder /app/var/static/staticfiles.json /app/var/static/staticfiles.json