- backend/Dockerfile: split builder/runner, runtime libs only, non-root app user, curl for healthcheck, --frozen via new uv.lock - frontend/Dockerfile: npm ci instead of npm install (deterministic), USER node - docker-compose.prod.yml: working backend healthcheck (curl now in image), redis healthcheck, drop dead NEXT_PUBLIC_API_BASE_URL env (Next.js bakes NEXT_PUBLIC_* at build time, runtime override is no-op) - docker-compose.yml: same redis healthcheck, BACKEND_URL for next.config rewrites, drop uv from CMD (not in new image) - Caddyfile: handle (not handle_path) so /api prefix is preserved into FastAPI router - next.config.ts: rewrite /api/* and /health to BACKEND_URL in dev (no Caddy locally) - frontend/src/lib/api.ts: empty default = same-origin relative URLs - Makefile: drop uv run from migrate target - Add backend/uv.lock and frontend/package-lock.json for reproducible builds Verified: docker build succeeds for both, backend container starts, /health responds, curl healthcheck works inside image, container runs as non-root. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
59 lines
1.3 KiB
Docker
59 lines
1.3 KiB
Docker
# syntax=docker/dockerfile:1.7
|
|
|
|
# ---- builder ----
|
|
FROM python:3.12-slim AS builder
|
|
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
UV_COMPILE_BYTECODE=1 \
|
|
UV_LINK_MODE=copy
|
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
build-essential \
|
|
libpq-dev \
|
|
libgdal-dev \
|
|
libproj-dev \
|
|
libgeos-dev \
|
|
&& rm -rf /var/lib/apt/lists/*
|
|
|
|
RUN pip install --no-cache-dir uv
|
|
|
|
WORKDIR /app
|
|
|
|
COPY pyproject.toml uv.lock* ./
|
|
RUN if [ -f uv.lock ]; then uv sync --frozen --no-dev; else uv sync --no-dev; fi
|
|
|
|
COPY app ./app
|
|
|
|
|
|
# ---- runner ----
|
|
FROM python:3.12-slim AS runner
|
|
|
|
ENV PYTHONUNBUFFERED=1 \
|
|
PYTHONDONTWRITEBYTECODE=1 \
|
|
PATH="/app/.venv/bin:$PATH"
|
|
|
|
# Runtime libs only — no -dev / no build-essential.
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
libpq5 \
|
|
libgdal36 \
|
|
libproj25 \
|
|
libgeos-c1t64 \
|
|
libcairo2 \
|
|
libpango-1.0-0 \
|
|
libpangoft2-1.0-0 \
|
|
fonts-dejavu-core \
|
|
curl \
|
|
&& rm -rf /var/lib/apt/lists/* \
|
|
&& useradd --create-home --uid 1000 app
|
|
|
|
WORKDIR /app
|
|
|
|
COPY --from=builder --chown=app:app /app/.venv /app/.venv
|
|
COPY --from=builder --chown=app:app /app/app /app/app
|
|
|
|
USER app
|
|
|
|
EXPOSE 8000
|
|
|
|
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
|