# Self-contained Augur CI image: roost + a baked cold-start model.
# Build (from the repo root, with a model already built via `roost package`):
#   docker build -t augur-ci .
# Use in CI (repo checked out at $PWD, full history):
#   docker run --rm -v "$PWD:/repo" augur-ci --repo /repo --commit <sha> --format md
#
# The baked model carries NO training-source names (scrubbed at package time).
FROM python:3.12-slim

# git: mine the repo's history.  libgomp1: OpenMP runtime LightGBM's native lib needs.
RUN apt-get update && apt-get install -y --no-install-recommends git libgomp1 \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY pyproject.toml README.md ./
COPY src ./src
RUN pip install --no-cache-dir .

# Bake the cold-start model into the image (built locally beforehand).
# data/models is gitignored, so this COPY uses your local build context.
COPY data/models/augur-cold-start-*.joblib /opt/augur/
ENV ROOST_MODEL=/opt/augur/

# Resolve ROOST_MODEL to the actual file at build time.
RUN MODEL=$(ls /opt/augur/augur-cold-start-*.joblib | head -1) \
    && printf 'ROOST_MODEL=%s\n' "$MODEL" > /opt/augur/env \
    && echo "baked model: $MODEL"

ENTRYPOINT ["sh", "-c", ". /opt/augur/env && export ROOST_MODEL && exec roost ci \"$@\"", "--"]
