# Build on any Python 3.12 image. On a network without internet access, point
# BASE_IMAGE at your mirror and PIP_INDEX_URL at your package index, and copy
# the field kit's Kamiwaza wheels into wheels/. kz-ext dev and kz-ext dev local
# pass both arguments through from your shell:
#   export BASE_IMAGE=registry.internal/python:3.12-slim
#   export PIP_INDEX_URL=https://pypi.internal/simple
ARG BASE_IMAGE=python:3.12-slim
FROM ${BASE_IMAGE}

ARG PIP_INDEX_URL

RUN groupadd -r -g 1001 appuser && useradd -r -u 1001 -g appuser -d /app appuser

WORKDIR /app

COPY requirements.txt .
# Kamiwaza wheels for an offline build; empty when installing from PyPI.
# kz-ext create and kz-ext update always create wheels/ (wheels/README.md).
# Keep this a plain COPY: a missing folder means a broken project and must
# stop the build.
COPY wheels ./wheels
RUN pip install --no-cache-dir ${PIP_INDEX_URL:+--index-url "$PIP_INDEX_URL"} -r requirements.txt

COPY src ./src

USER 1001

EXPOSE 8080

CMD ["uvicorn", "src.server:app", "--host", "0.0.0.0", "--port", "8080"]
