-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dockerfile
80 lines (61 loc) · 2.11 KB
/
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
FROM debian:12.5 AS base
RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \
--mount=target=/var/cache/apt,type=cache,sharing=locked \
apt-get update && apt-get install --no-install-recommends -yq python3 python3-pip git python3-venv python3-dev gettext curl
WORKDIR /app
RUN python3 -m venv .venv
ENV PYTHONPATH=/app/.venv/lib
ENV PATH=/app/.venv/bin:$PATH
COPY ./pyproject.toml .
COPY src/manage.py src/
RUN pip install -e .
FROM base AS base-node
RUN curl -fsSL https://deb.nodesource.com/setup_18.x -o nodesource_setup.sh
RUN bash nodesource_setup.sh
RUN --mount=target=/var/lib/apt/lists,type=cache,sharing=locked \
--mount=target=/var/cache/apt,type=cache,sharing=locked \
apt-get install -y nodejs npm
FROM scratch AS source
WORKDIR /app
COPY src src
FROM node:20 AS frontend-base
WORKDIR /app
COPY src/frontend/package.json src/frontend/package-lock.json .
RUN npm install
FROM frontend-base AS frontend
COPY src/frontend/src src
COPY src/frontend/vite.config.js src/frontend/.eslintrc.cjs .
FROM frontend AS frontend-prod
RUN npm run build
FROM base AS production
RUN pip install -e .[prod]
# Compile the translations for multilanguage
FROM base AS translation
COPY --from=source /app .
RUN DATABASE_URL="" \
DJANGO_SETTINGS_MODULE="config.settings.test" \
manage.py compilemessages -l no
FROM base-node AS tailwind
COPY --from=source /app .
RUN DATABASE_URL="" \
DJANGO_SETTINGS_MODULE="config.settings.test" \
manage.py tailwind install
RUN DATABASE_URL="" \
DJANGO_SETTINGS_MODULE="config.settings.test" \
manage.py tailwind build
FROM base AS django
COPY --from=production /app .
COPY --from=translation /app/src/locale /app/src/locale
COPY --from=source /app .
COPY --from=tailwind /app/src/theme/static /app/src/theme/static
COPY --from=frontend-prod /app/static /app/src/frontend/static
RUN mkdir media
COPY entrypoint.sh .
ENTRYPOINT ["./entrypoint.sh"]
FROM base-node AS dev
RUN pip install -e .[dev]
COPY --from=django /app/src src
COPY --from=translation /app/src/locale /app/src/locale
COPY --from=django /app/entrypoint.sh .
COPY entrypoint.sh .
ENTRYPOINT ["./entrypoint.sh"]