FROM python:3.14-slim AS base
WORKDIR /app

FROM base AS builder
# Copy pyproject.toml and README.md first to leverage Docker cache
COPY pyproject.toml README.md ./
# We can use pip to install the project in editable mode or just dependencies
RUN pip install --no-cache-dir .

FROM base
LABEL org.opencontainers.image.source="http://gitea.lan/jacobh2/babymonitor"
LABEL org.opencontainers.image.description="Babymonitor Backend"

# Copy installed packages from builder
COPY --from=builder /usr/local/lib/python3.14/site-packages /usr/local/lib/python3.14/site-packages
COPY --from=builder /usr/local/bin /usr/local/bin
COPY app/ ./app/
RUN mkdir -p /app/data
EXPOSE 8000
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
