# syntax=docker/dockerfile:1
FROM python:3.12-slim

# Install uv (same tool you're using locally)
COPY --from=ghcr.io/astral-sh/uv:latest /uv /usr/local/bin/uv

WORKDIR /app

# Copy dependency files first (better layer caching —
# Docker only re-installs deps when these files change)
COPY pyproject.toml uv.lock ./

# Install dependencies into the system Python (no venv needed in containers)
RUN uv sync --frozen --no-dev --no-editable

# Copy the rest of the app
COPY app.py ./
COPY templates/ ./templates/

# visitor_count.json is runtime state — don't bake it into the image.
# It'll be created fresh (or mounted from a volume) at runtime.

EXPOSE 5000

# uv run finds gunicorn inside the venv it manages —
# same idea as `cargo run` finding your binary in target/
CMD ["uv", "run", "gunicorn", "--bind", "0.0.0.0:5000", "--workers", "2", "app:app"]
