Skip to contents

The 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.

Usage

repro_run_scripts_docker(
  run_tbl,
  order,
  sandbox_root,
  lib_dir = NULL,
  image = "rocker/r-ver:latest",
  timeout = 600,
  skip = character(0),
  parses = NULL,
  failed_deps = character(0),
  deadline = NULL,
  net = NULL
)

Arguments

run_tbl

repro_write_scripts() output (file_name, script_path, run_dir) — run_dir must 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 /rlib when 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 as skipped_missing_inputs instead of running

parses

named logical (by file_name); a file that will not parse is recorded not_parsed and 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 as skipped_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 (outcome download_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)
} # }