# CT-conformance step image.
#
# Extends the Mediforce golden image with our own validation packages, so the
# deterministic step runs the same rules we ship elsewhere.
#
# Build via ../scripts/build-image.sh — it stages p21bridge into the build
# context first (the package lives outside this tree).

FROM mediforce-golden-image

# jsonlite for the report, haven for .xpt. admiral/haven are already present in
# the clinical images but the golden image is the smaller base, so be explicit.
RUN install2.r --error --skipinstalled haven jsonlite

COPY p21bridge /tmp/p21bridge
RUN R CMD INSTALL /tmp/p21bridge && rm -rf /tmp/p21bridge

COPY ct-conformance-check.R /opt/clincoder/ct-conformance-check.R
COPY structural-check.R     /opt/clincoder/structural-check.R
COPY consistency-check.R    /opt/clincoder/consistency-check.R
COPY temporal-check.R       /opt/clincoder/temporal-check.R
COPY make-fixture.R         /opt/clincoder/make-fixture.R
COPY sdtm-check             /usr/local/bin/sdtm-check
RUN chmod +x /usr/local/bin/sdtm-check

# A `script` step gets the run's git worktree at /workspace and a collected
# /output (which also carries the step input as /output/input.json). There is
# no /data mount — that is the *agent* plugin's convention, not this one.
# SDTM lives at /workspace/sdtm, matching the layout of the real agent run
# branches in Appsilon/mediforce-clinical-workspace.
WORKDIR /workspace
