Skip to contents

Generates a dockerfile based on an renv.lock file, ensuring reproducible package dependencies in the container.

Usage

dk_from_renv(
  lock_file = "renv.lock",
  r_version = NULL,
  base_image = NULL,
  include_sysreqs = TRUE
)

Arguments

lock_file

Path to renv.lock file

r_version

R version to use (default: from lock file)

base_image

Base image to use (default: determined from R version)

include_sysreqs

Include system requirements (default: TRUE)

Value

A dockerfile object configured based on the renv.lock file

Details

This function:

  • Extracts the R version from the lock file (if available)

  • Uses the appropriate rocker/r-ver base image

  • Adds system requirements for the packages in the lock file

  • Sets up renv and restores the packages from the lock file

The resulting dockerfile will recreate the exact environment specified in your renv.lock file, ensuring reproducible results.

See also

dk_from_session() for creating from the current session, dk_from_description() for creating from DESCRIPTION files, & dk_add_sysreqs() for adding system requirements

Other dockerfile from environment functions: dk_from_description(), dk_from_script(), dk_from_session()

Examples

if (FALSE) { # \dontrun{
# Create a dockerfile from an renv.lock file
df <- dk_from_renv("renv.lock")

# Specify a different R version
df <- dk_from_renv("renv.lock", r_version = "4.4.0")
} # }