# syntax=docker/dockerfile:1
# The mock bundle owns its whole image recipe. The generic builder stages this
# directory beside the shared SDK workspace; nothing in docker/ or ops/ selects
# this bundle's base, engine, binary, or pins.
#
# The builder image and the runtime base are pinned here, inside the bundle.
ARG RUST_IMAGE=rust:1.99.1-bookworm@sha256:e6f2cff35d0f309acf8433b4f05878ed77092602c5065cc81801177da0bb3a9c
ARG DEBIAN_IMAGE=debian:bookworm-slim@sha256:734a72b3d6142a71993b4bc580ca01d8ca687f77a2c422d96a961d3376b179bc

FROM ${RUST_IMAGE} AS build
WORKDIR /src
# A bundle is its own workspace (D19). The root manifests and crates are in the
# generic context because the bundle's path dependencies reach them. The
# registry and target caches are BuildKit mounts, not image layers.
COPY Cargo.toml Cargo.lock ./
COPY crates ./crates
COPY plugins/mock/x64-cpu ./plugins/mock/x64-cpu
RUN --mount=type=cache,target=/usr/local/cargo/registry \
    --mount=type=cache,target=/cache/target \
    CARGO_TARGET_DIR=/cache/target \
    cargo build --locked --release \
        --manifest-path plugins/mock/x64-cpu/Cargo.toml \
        --bin inf3r-mock-x64-cpu \
    && install -D -m 0755 /cache/target/release/inf3r-mock-x64-cpu /out/inf3r-mock-x64-cpu

FROM ${DEBIAN_IMAGE}
# The image is runtime-only: the plugin and the manifest tree, no weights and
# no compiler. /bin/sh and find stay because the generic image check runs an
# explicit weight scan inside the image.
RUN install -d /opt/inf3r/bin /opt/inf3r/plugins /var/lib/inf3r
COPY plugins/mock/x64-cpu/bundle.toml plugins/mock/x64-cpu/target.toml plugins/mock/x64-cpu/BUNDLE.md \
    /opt/inf3r/plugins/mock/x64-cpu/
COPY plugins/mock/x64-cpu/models /opt/inf3r/plugins/mock/x64-cpu/models
COPY plugins/mock/x64-cpu/engine /opt/inf3r/plugins/mock/x64-cpu/engine
COPY --from=build --chmod=0755 /out/inf3r-mock-x64-cpu /opt/inf3r/bin/inf3r-mock-x64-cpu
ENV INF3R_BUNDLE_DIR=/opt/inf3r/plugins/mock/x64-cpu
# Rootless Docker maps container root to the daemon's unprivileged host uid.
USER 0:0
