# 1. Start from an official image that already contains Python.
FROM python:3.12-slim

# 2. Every following command runs inside /app in the container.
WORKDIR /app

# 3. Install the dependencies first. Docker caches this layer, so it is
#    only re-run when requirements.txt changes, not on every code change.
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# 4. Copy the application code.
COPY app/ app/

# 5. Document the port, and say how to start the app. 0.0.0.0 makes the
#    server reachable from outside the container, not just from inside it.
EXPOSE 8000
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "app.main:app"]
