-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
118 lines (96 loc) · 2.61 KB
/
Copy pathDockerfile
File metadata and controls
118 lines (96 loc) · 2.61 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
########################
# BUILDER STAGE
########################
FROM python:3.14-alpine AS builder
COPY --from=ghcr.io/astral-sh/uv:0.11.3 /uv /uvx /bin/
ENV PYTHONUNBUFFERED=1 \
PIP_NO_CACHE_DIR=on \
HOME=/tmp \
TMPDIR=/tmp \
AZURE_CONFIG_DIR=/tmp/.azure \
COVERAGE_FILE=/tmp/.coverage \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPYCACHEPREFIX=/tmp/pycache \
XDG_CACHE_HOME=/tmp/.cache \
UV_CACHE_DIR=${XDG_CACHE_HOME}/uv \
UV_PROJECT_ENVIRONMENT=/app/.venv
WORKDIR /app
# Build-only packages
RUN apk add --no-cache --virtual .build-deps \
build-base \
linux-headers
# Install dependencies
COPY pyproject.toml ./
COPY uv.lock ./
RUN uv sync --frozen
# Copy application code
COPY manage.py ./
COPY uwsgi.ini ./
COPY gunicorn.conf.py ./
COPY core ./core
COPY deploy ./deploy
COPY notification ./notification
# Collect static assets
RUN DJANGO_SETTINGS_MODULE=core.settings.base uv run python manage.py collectstatic --no-input
########################
# RUNTIME STAGE
########################
FROM python:3.14-alpine AS runtime
ENV PYTHONUNBUFFERED=1 \
HOME=/tmp \
TMPDIR=/tmp \
AZURE_CONFIG_DIR=/tmp/.azure \
COVERAGE_FILE=/tmp/.coverage \
PYTHONDONTWRITEBYTECODE=1 \
PYTHONPYCACHEPREFIX=/tmp/pycache \
XDG_CACHE_HOME=/tmp/.cache \
PATH="/app/.venv/bin:$PATH"
WORKDIR /app
# Runtime packages
RUN apk add --no-cache \
libheif \
bash \
curl
ARG APP_UID=1000
ARG APP_GID=1000
RUN addgroup -S -g ${APP_GID} app \
&& adduser -S -D -u ${APP_UID} -G app appuser
COPY --from=builder --chown=appuser:app /app /app
USER appuser
RUN mkdir -p "$AZURE_CONFIG_DIR" "$PYTHONPYCACHEPREFIX"
### Linting stage for administrative tasks
# Needs root to write to the home dir and uv runtime
FROM runtime AS lint
COPY --from=ghcr.io/astral-sh/uv:0.11.3 /uv /uvx /bin/
ENV UV_CACHE_DIR=${XDG_CACHE_HOME}/uv \
UV_PROJECT_ENVIRONMENT=/app/.venv
USER root
### City Pass stages
FROM runtime AS app-city_pass
COPY city_pass /app/city_pass
### Modules stages
FROM runtime AS app-modules
COPY modules /app/modules
### Contact stages
FROM runtime AS app-contact
COPY contact /app/contact
### Construction Work stages
FROM runtime AS app-construction_work
COPY construction_work /app/construction_work
### News stages
FROM runtime AS app-news
COPY news /app/news
### Bridge stages
FROM runtime AS app-bridge
COPY bridge /app/bridge
### Notification stages
FROM runtime AS app-notification
### Image stages
FROM runtime AS app-image
COPY image /app/image
### Waste stages
FROM runtime AS app-waste
COPY waste /app/waste
### Survey stages
FROM runtime AS app-survey
COPY survey /app/survey