Skip to contents

Identifies and adds the necessary system requirements for R packages to a dockerfile using the pak package to determine dependencies.

Usage

dk_add_sysreqs(dockerfile, packages, package_manager = "auto")

Arguments

dockerfile

A dockerfile object

packages

Character vector of package names

package_manager

Package manager to use (default: "auto")

Value

An updated dockerfile object with system requirements added

Details

This function uses the pak package to determine the system requirements for the specified R packages. It then formats the appropriate installation commands for the detected package manager and adds them as RUN instructions to the dockerfile.

The pak package must be installed for this function to work.

See also

generate_pkg_install_cmd() for generating package installation commands & determine_package_manager() for determining the package manager

Other utility functions: determine_linux_distribution(), determine_package_manager(), map_to_sysreqs_platform()

Examples

if (FALSE) { # \dontrun{
# Create a dockerfile
df <- dockerfile() |>
  dfi_from("rocker/r-ver:4.4.0")

# Add system requirements for packages
df <- dk_add_sysreqs(df, c("xml2", "RPostgreSQL", "rJava"))
} # }