# Phase 1 onboarding sandbox: a CLEAN machine, the way a new engineer's is.
#
# The whole point of this image is what it does NOT contain: no uv, no pipx, no
# global mdl, no project .venv, none of the PATH entries a developer's own shell
# profile accumulates. debian:stable-slim ships a system Python but no Python
# packaging tooling, so "fresh machine to `mdl --help`" is tested honestly -
# including the step where the engineer first has to install uv itself.
#
# We install NOTHING Modelith-related at build time on purpose. The build only
# lays down the bare prerequisites a real fresh machine already has (curl, ca
# certs, git, the `time` command). Everything the acceptance bars measure -
# installing uv, `uv tool install modelith-dbt`, the demo loop - happens inside
# run-phase1.sh at RUN time, where it can be timed and asserted.
FROM debian:stable-slim

# MODELITH_VERSION pins exactly what a new engineer gets from the blessed path
# today. Override at build time to test a different release:
#   docker build --build-arg MODELITH_VERSION=0.3.1 ...
ARG MODELITH_VERSION=0.3.0
ENV MODELITH_VERSION=${MODELITH_VERSION}

# Bare prerequisites only. curl to fetch the uv installer, ca-certificates for
# HTTPS to PyPI, git because dbt/model repos are git-native, and coreutils for a
# dependable `date`/`time`. Deliberately NOT installing python3-pip, pipx, or uv.
RUN apt-get update \
    && apt-get install -y --no-install-recommends \
        curl ca-certificates git coreutils \
    && rm -rf /var/lib/apt/lists/*

# Run as a non-root user, like a real developer account. uv tool install targets
# ~/.local/bin for this user, exactly as it would on a laptop.
RUN useradd -m -s /bin/bash engineer
USER engineer
WORKDIR /home/engineer

# The harness is the only thing we copy in. It does the timed install + demo loop.
COPY --chown=engineer:engineer run-phase1.sh /home/engineer/run-phase1.sh

# Default: run the full Phase 1 acceptance harness. Override with `bash` to poke
# around interactively (docker run --rm -it modelith-onboarding bash).
ENTRYPOINT ["/bin/bash", "/home/engineer/run-phase1.sh"]
