-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
60 lines (47 loc) · 1.92 KB
/
Dockerfile
File metadata and controls
60 lines (47 loc) · 1.92 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
# Multi-stage build for production
# Stage 1: Build frontend
FROM node:20-alpine AS frontend-builder
WORKDIR /app
COPY frontend/package*.json ./
RUN npm ci
COPY frontend/ ./
# Provide build metadata to the frontend bundle so client-side version checks
# use the same values the backend reports at runtime.
COPY VERSION /VERSION
COPY GIT_COMMIT /GIT_COMMIT
RUN npm run build
# Stage 2: Python backend with built frontend
FROM python:3.13-slim
WORKDIR /app
# Set non-interactive mode for apt to avoid warnings
ENV DEBIAN_FRONTEND=noninteractive
# Install system dependencies and create user
COPY scripts/install-system-deps /tmp/
RUN bash /tmp/install-system-deps && \
rm /tmp/install-system-deps && \
useradd -m -u 1000 sambee && \
mkdir -p /app/data && \
chown sambee:sambee /app/data
# Copy ImageMagick policy and metadata files
COPY imagemagick-policy.xml /etc/ImageMagick-7/policy.xml
# Copy backend dependency lockfile first for better caching (changes rarely)
COPY backend/requirements.lock.txt ./
# Install Python dependencies before copying full backend (changes rarely - better layer caching)
RUN pip install --root-user-action=ignore --disable-pip-version-check --no-cache-dir --require-hashes -r requirements.lock.txt
# Copy version metadata (changes often)
COPY VERSION /VERSION
COPY GIT_COMMIT /GIT_COMMIT
# Generate build timestamp (runs after GIT_COMMIT copy, so cache busts on every commit)
RUN date -u +"%Y-%m-%dT%H:%M:%SZ" > /BUILD_TIME
# Copy backend code and built frontend (change often)
COPY backend/ ./
COPY --from=frontend-builder /app/dist ./static
# Switch to non-root user
USER sambee
# Expose port
EXPOSE 8000
# Health check (wget is installed via install-system-deps script)
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
CMD wget -qO- http://localhost:8000/api/health >/dev/null || exit 1
# Run the application
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]