
Run the paper's scripts, in order, each in an isolated Docker container
Source:R/reproducibility_check_docker.R
repro_run_scripts_docker.RdThe Docker-backed twin of repro_run_scripts(): same return contract, same
per-script semantics (skip on missing inputs / parse failure, timeout,
undefined-variable / dependency-unavailable classification, captured
result objects), but each script runs via docker run --network none --read-only --user <non-root> instead of a callr subprocess — so the
code cannot reach the network (unless net is given) or touch anything
outside the mounted sandbox and library, even deliberately. See this file's header comment for
the two-phase (install-then-run) design and why the library is mounted at
/rlib, not /lib.
Arguments
- run_tbl
repro_write_scripts()output (file_name,script_path,run_dir) —run_dirmust be the SAME directory as (or a subdirectory of)sandbox_root, so it can be bind-mounted as a whole- order
a vector of
file_names in the order to run- sandbox_root
the materialised layout root on the HOST (from
repro_materialize_layout()) — mounted read-write at/sandbox- lib_dir
throwaway library ON THE HOST (or NULL) — mounted at
/rlibwhen supplied, writable, so a package can keep data in its own folder- image
the Docker image to run scripts in (see
.repro_docker_image_for())- timeout
per-script timeout in seconds
- skip
character vector of
file_names to record asskipped_missing_inputsinstead of running- parses
named logical (by file_name); a file that will not parse is recorded
not_parsedand not run- failed_deps
character vector of package names
repro_install_deps_docker()could not install- deadline
the time (
Sys.time()plus the time for all scripts together) after which no script is started, recorded asskipped_time_limit; a running script is stopped then.NULL(the default) sets no such limit.- net
NULL(the default) runs with the network off. With the limits from.repro_download_limits(), scripts can use the internet, and a script is stopped (outcomedownload_too_large) when the scripts together download more than the total limit, or a file larger than the limit per file appears.
Value
a data frame — identical columns to repro_run_scripts()'s
return: file_name, outcome, error, error_type, undefined_var,
stdout, stderr, elapsed, script_lines, captures
Examples
if (FALSE) { # \dontrun{
# needs Docker
root <- file.path(tempdir(), "run_demo")
plan <- data.frame(file_name = "analysis.R", target_path = "analysis/analysis.R")
code <- list(analysis.R = c("x <- c(1, 2, 3)", "print(mean(x))"))
run_tbl <- repro_write_scripts(code, list(), plan, root)
repro_run_scripts_docker(run_tbl, order = "analysis.R", sandbox_root = root)
} # }