-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathDockerfile
More file actions
47 lines (33 loc) · 1.76 KB
/
Dockerfile
File metadata and controls
47 lines (33 loc) · 1.76 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
# syntax=docker/dockerfile:1
# ── Build stage ──────────────────────────────────────────────────────────────
# Uses the official uv image to resolve and install dependencies into a venv.
FROM ghcr.io/astral-sh/uv:python3.14-bookworm-slim AS builder
WORKDIR /app
# Copy only the dependency manifest first so Docker layer caching skips the
# install step when only application source code changes.
COPY pyproject.toml uv.lock* ./
# Install production dependencies into /app/.venv.
# --frozen ensures the lock file is used as-is; --no-dev omits dev tools.
RUN uv sync --frozen --no-dev --no-install-project
# Now copy the rest of the source and install the project itself.
# README.md is required by hatchling (declared as readme in pyproject.toml).
COPY README.md entrypoint.sh alembic.ini ./
COPY pg_atlas/ ./pg_atlas/
RUN uv sync --frozen --no-dev
# ── Runtime stage ─────────────────────────────────────────────────────────────
FROM python:3.14-slim-bookworm AS runtime
WORKDIR /app
# Copy the pre-built virtual environment from the builder stage.
COPY --from=builder /app/.venv /app/.venv
# Copy the entrypoint and Alembic requirements.
COPY --from=builder /app/entrypoint.sh ./
COPY --from=builder /app/alembic.ini ./
# Copy application source.
COPY --from=builder /app/pg_atlas ./pg_atlas/
# Activate the venv by prepending it to PATH.
ENV PATH="/app/.venv/bin:$PATH"
# Expose the API port.
EXPOSE 8000
# Apply DB migrations
ENTRYPOINT [ "./entrypoint.sh" ]
CMD ["uvicorn", "pg_atlas.main:app", "--host", "0.0.0.0", "--port", "8000"]