# issue-core REST ingestion service image.
#
# Builds the checked-out issue-core[api] package and runs the FastAPI ingestion
# server on :8765. The image is published to
# gitea.coulomb.social/coulomb/issue-core.
FROM python:3.12-slim AS runtime

ENV PYTHONUNBUFFERED=1 \
    PYTHONDONTWRITEBYTECODE=1 \
    HOME=/home/app

# Non-root runtime user; HOME drives issue-core's config dir
# (~/.config/issue-tracker/backends.json).
RUN useradd --create-home --home-dir /home/app --uid 10001 app

WORKDIR /src
COPY pyproject.toml README.md LICENSE ./
COPY issue_core ./issue_core
RUN pip install --no-cache-dir --index-url https://pypi.org/simple ".[api]" \
    && rm -rf /src

COPY docker-entrypoint.sh /usr/local/bin/docker-entrypoint.sh
RUN chmod +x /usr/local/bin/docker-entrypoint.sh

USER app
EXPOSE 8765

# Entrypoint renders backends.json from env, then execs the server.
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]