End-to-end orchestrator that scans an R project, compiles multi-target
container definitions (Dockerfile, docker-compose.yml, Apptainer.def),
statically lints every generated spec, records a cryptographically verifiable
capsule.json provenance manifest, and optionally runs an isolated
reproducibility verification audit and renders journal-ready certificates.
Usage
build_capsule(
path = ".",
targets = c("dockerfile", "compose", "apptainer"),
inputs = NULL,
outputs = NULL,
entrypoint = NULL,
seed = NULL,
tolerances = NULL,
key = NULL,
write = TRUE,
lint = TRUE,
verify = FALSE,
certificate = FALSE,
runner = c("sandbox", "docker"),
custom_sysreqs = NULL,
platform = NULL,
use_ppm = TRUE,
metadata = list()
)Arguments
- path
Path to the project root directory. Defaults to
".".- targets
Character vector of container targets to compile: any subset of
c("dockerfile", "compose", "apptainer").- inputs
Optional character vector of input data file/directory paths.
- outputs
Optional character vector of output artifact paths to hash and verify.
- entrypoint
Optional runnable entrypoint override.
- seed
Optional integer RNG seed.
- tolerances
Optional numeric tolerance configuration passed to
create_capsule_manifest().- key
Optional HMAC-SHA256 secret key for signing
capsule.json.- write
Logical; if
TRUE(default), writes compiled container specs andcapsule.jsonintopath.- lint
Logical; if
TRUE(default), runslint_container_spec()on every compiled container target.- verify
Logical; if
TRUE, executesverify_capsule()immediately after building the manifest. Defaults toFALSE.- certificate
Logical; if
TRUE(andverify = TRUE), renders Markdown and HTML certificates viarender_certificate(). Defaults toFALSE.- runner
Verification runner backend when
verify = TRUE:"sandbox"(default) or"docker".- custom_sysreqs
Optional custom system dependency overrides forwarded to
scan_project().- platform
Optional target container platform (
"linux/amd64","linux/arm64", orNULL) forwarded tocompile_dockerfile()andcompile_compose().- use_ppm
Logical; if
TRUE(default), enables Posit Package Manager Linux binary repositories incompile_dockerfile().- metadata
Optional metadata list forwarded to
create_capsule_manifest().
Value
An S3 object of class rcapsule_bundle containing scan, specs,
lint, manifest, verification, and certificate.
Examples
tmp <- tempfile("rcapsule_bundle_")
dir.create(tmp)
writeLines(
c("write.csv(data.frame(x = 1:3, y = c(2, 4, 6)), 'out.csv', row.names = FALSE)"),
file.path(tmp, "run.R")
)
write.csv(data.frame(x = 1:3, y = c(2, 4, 6)), file.path(tmp, "out.csv"), row.names = FALSE)
bundle <- build_capsule(tmp, outputs = "out.csv", seed = 42L, verify = TRUE, certificate = TRUE)
bundle$verification$status
#> [1] "verified_exact"
unlink(tmp, recursive = TRUE)
