# Base image pulled via the Docker Hub mirror (mirror.gcr.io) to avoid
# registry-1.docker.io timeouts. Revert to `python:3.12-slim` if pulling
# direct from Docker Hub works in your environment.
FROM mirror.gcr.io/library/python:3.12-slim

# Prevents Python from writing .pyc files and buffering stdout/stderr.
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1

WORKDIR /app

# System deps (kept minimal). build-essential is occasionally needed by wheels.
RUN apt-get update \
    && apt-get install -y --no-install-recommends curl \
    && rm -rf /var/lib/apt/lists/*

COPY requirements.txt .
RUN pip install --no-cache-dir --upgrade pip \
    && pip install --no-cache-dir -r requirements.txt

COPY . .

EXPOSE 8000

# entrypoint.sh waits for the DB, creates tables, seeds the admin, then launches uvicorn.
RUN chmod +x ./entrypoint.sh
CMD ["./entrypoint.sh"]
