# tidal-stress load generator image.
#
# Build context is this repository's root (the workspace Cargo.toml / Cargo.lock
# and every member manifest live there). Build from the repo root:
#
#     docker build -f docker/stress/Dockerfile -t tidaldb:stress .
#
# tidal-stress is a pure-Rust HTTP client (tokio + reqwest/rustls): it depends on
# NONE of the engine crates, so this build never compiles tidal/tidal-net/usearch
# and needs no protoc/g++. Pin the builder to bookworm so its glibc matches the
# runtime; trixie's vectorized-math libmvec is handled by the trixie runtime below.
FROM rust:1.91-bookworm AS builder
ARG DEBIAN_FRONTEND=noninteractive
WORKDIR /app

# Copy the full (already-pruned by .dockerignore) workspace and build only the
# load generator. The unified workspace requires every member manifest present to
# resolve metadata, so copy the whole context rather than a fragile subset.
COPY . .
RUN cargo build -p tidal-stress --release --locked

FROM debian:trixie-slim
ARG DEBIAN_FRONTEND=noninteractive
WORKDIR /srv

# ca-certificates only matters if a target is https:// (in-cluster targets are
# plaintext http://); kept for completeness. No libstdc++ (no C++ in this crate).
RUN useradd --system --home /srv stress && \
    apt-get update && apt-get install -y --no-install-recommends ca-certificates && \
    rm -rf /var/lib/apt/lists/*

COPY --from=builder /app/target/release/tidal-stress /usr/local/bin/tidal-stress
# soak-eval: the 30-night streak evaluator (built from the same crate; see
# tidal-stress/src/bin/soak-eval.rs). The soak monitor's evaluator container runs
# it to join ledger.tsv + restarts.tsv into the honest streak verdict.
COPY --from=builder /app/target/release/soak-eval /usr/local/bin/soak-eval

USER stress

# ENTRYPOINT is the bare binary so the Job supplies the full ramp/mix/target argv.
ENTRYPOINT ["tidal-stress"]
