-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
28 lines (18 loc) · 996 Bytes
/
Dockerfile
File metadata and controls
28 lines (18 loc) · 996 Bytes
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
# ── Stage 1: install dependencies ──────────────────────────────────────────
FROM python:3.12-slim AS builder
WORKDIR /build
COPY requirements.txt .
RUN pip install --no-cache-dir --prefix=/install -r requirements.txt
# ── Stage 2: runtime image ──────────────────────────────────────────────────
FROM python:3.12-slim
WORKDIR /app
# Non-root user for security
RUN useradd --create-home --shell /bin/bash appuser
COPY --from=builder /install /usr/local
COPY app/ ./app/
COPY migrations/ ./migrations/
USER appuser
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/api/v1/health')"
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "1"]