prepare_docker_image: Prepare Docker Image

Description Usage Arguments Value Examples

View source: R/prepare_docker_image.R

Description

Prepares a Docker r-base image for your R package by (1) building and installing the package on your system, (2) identifying R package dependencies of the package, (3) detecting the version numbers of the loaded and installed versions of these packages on your system, (4) linking the individual packages to the right repositories (either CRAN or local repos) and (5) writing Dockerfile and creating all other files needed to build the Docker r-base image.

Usage

1
2
3
4
5
prepare_docker_image(pkg = ".", dir_image = NULL,
  print_dockerfile = FALSE, dir_install = NULL, verbose = TRUE,
  r_version = NULL, dependencies = c("Depends", "Imports",
  "LinkingTo"), base = FALSE, recommended = FALSE, dir_src = NULL,
  prioritize_cran = TRUE, overwrite = TRUE, ...)

Arguments

pkg

Path to a package, or within a package.

dir_image

character directory where to create folder for all files for the Docker image, from where the Docker image can be build.

print_dockerfile

logical should the resulting Dockerfile be printed?

dir_install

character where should the package be installed on your system. Choose from 'auto' (automatic detection), 'temp' (temporary directory) or specify directory yourself.

verbose

logical should messages be printed or not?

r_version

character which version of base R to include in the Docker image, e.g. '3.6.0'. Defaults to NULL, which implies that the active version of R will apply.

dependencies

character vector of dependency types to include. Choices are "Depends", "Imports", "LinkingTo", "Suggests", and "Enhances". Defaults to c("Depends", "Imports", "LinkingTo").

base

Logical indicating whether to include dependencies on base packages that are included in the R installation. Defaults to FALSE.

recommended

Logical indicating whether to include dependencies on recommended packages that are included in the R installation. Defaults to FALSE.

dir_src

character directories with local source packages. Note, the source packages must have filenames like (packageName)_(packageVersion).tar.gz, e.g. "recorder_0.8.2.tar.gz". Put directories in prioritized order. The first directory will have the highest priority.

prioritize_cran

logical should R dependency packages matched with CRAN be prioritized over matches with local source packages?

overwrite

logical if the directory for the files for the Docker image already exists and is non-empty, should it be deleted/overwritten?

...

optional arguments for 'install.packages()'.

Value

list relevant meta data of the files, that constitute the Docker image. As a side effect all necessary files for the Docker image - including the resulting Dockerfile - are saved in the desired directory.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# retrieve package directory for the 'dockr' package.
package_dir <- system.file(package = "dockr")
# this concludes the preparations. 

# now for the real action.

# create all files for a Docker image for the package in the current directory.
img <- prepare_docker_image(pkg = package_dir, dir_image = tempdir(), dir_install = "temp")

# look up meta data for files for Docker image.
img

dockr documentation built on Dec. 20, 2019, 5:06 p.m.