Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
40 lines (31 loc) · 1.5 KB
/
Copy pathDockerfile
File metadata and controls
40 lines (31 loc) · 1.5 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
# Production image: builds the SPA and bakes it into the Django image, so one
# versioned artifact per release. On start (see docker-compose.prod.yml) the
# app copies /app/frontend_dist into a volume that Caddy serves directly.
FROM node:22-slim AS frontend-build
WORKDIR /frontend
COPY frontend/package.json frontend/package-lock.json* ./
RUN if [ -f package-lock.json ]; then npm ci; else npm install; fi
COPY frontend/ .
# Same-origin API in production: VITE_API_BASE_URL stays unset (api.ts → "").
RUN npm run build
FROM python:3.12-slim
LABEL org.opencontainers.image.title="ansehBAR" \
org.opencontainers.image.authors="Rüdiger Rolf <rrolf@uni-osnabrueck.de>" \
org.opencontainers.image.vendor="Universität Osnabrück (virtUOS)" \
org.opencontainers.image.licenses="Apache-2.0"
ENV PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
WORKDIR /app
# gettext for compilemessages (add `RUN python manage.py compilemessages` once
# the tool ships a locale/ directory). No compiler needed — wheels only.
RUN apt-get update \
&& apt-get install -y --no-install-recommends gettext ffmpeg \
&& rm -rf /var/lib/apt/lists/*
COPY backend/requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY backend/ .
COPY --from=frontend-build /frontend/dist /app/frontend_dist
EXPOSE 8000
# --proxy-headers: trust Caddy's X-Forwarded-* so https is detected.
CMD ["uvicorn", "config.asgi:application", "--host", "0.0.0.0", "--port", "8000", \
"--proxy-headers", "--forwarded-allow-ips", "*"]