-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdockerfile
More file actions
31 lines (22 loc) · 1.07 KB
/
dockerfile
File metadata and controls
31 lines (22 loc) · 1.07 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
# ── Stage 1: build deps ───────────────────────────────────────────────────────
FROM python:3.11-slim AS builder
WORKDIR /app
RUN pip install --upgrade pip pdm
COPY pyproject.toml .
RUN pdm install --prod --no-self --no-editable
# ── Stage 2: runtime ──────────────────────────────────────────────────────────
FROM python:3.11-slim
WORKDIR /app
# Install psycopg2 runtime lib
RUN apt-get update && apt-get install -y --no-install-recommends libpq5 && rm -rf /var/lib/apt/lists/*
# Copy virtualenv from builder
COPY --from=builder /app/.venv /app/.venv
ENV PATH="/app/.venv/bin:$PATH" \
PYTHONUNBUFFERED=1 \
PYTHONDONTWRITEBYTECODE=1
# Copy application source
COPY main.py models.py database.py ./
COPY alembic.ini ./
COPY alembic/ ./alembic/
EXPOSE 8000
CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000", "--workers", "2"]