dockerfile

0th

Percentile

dockerfile-method

Create a Dockerfile based on either a sessionInfo, a workspace or a file.

Usage
dockerfile(from = utils::sessionInfo(),
  image = getImageForVersion(getRVersionTag(from)),
  maintainer = Sys.info()[["user"]], save_image = FALSE,
  envir = .GlobalEnv, env = list(generator = paste("containerit",
  utils::packageVersion("containerit"))), soft = FALSE,
  offline = FALSE, copy = NULL, container_workdir = "/payload/",
  cmd = "R", entrypoint = NULL, add_self = FALSE, silent = FALSE,
  predetect = TRUE, versioned_libs = FALSE,
  versioned_packages = FALSE, filter_baseimage_pkgs = FALSE)
Arguments
from

The source of the information to construct the Dockerfile. Can be a sessionInfo object, a path to a file within the working direcotry, a DESCRIPTION file, or the path to a workspace). If NULL then no automatic derivation of dependencies happens. If a DESCRIPTION file, then the minimum R version (e.g. "R (3.3.0)") is used for the image version and all "Imports" are explicitly installed.

image

('>From-object or character) Specifes the image that shall be used for the Docker container (FROM instruction). By default, the image selection is based on the given session. Alternatively, use getImageForVersion(..) to get an existing image for a manually defined version of R, matching the version with tags from the base image rocker/r-ver (see details about the rocker/r-ver at 'https://hub.docker.com/r/rocker/r-ver/'). Or provide a correct image name yourself.

maintainer

Specify the maintainer of the Dockerfile. See documentation at 'https://docs.docker.com/engine/reference/builder/#maintainer'. Defaults to Sys.info()[["user"]]. Can be removed with NULL.

save_image

When TRUE, it calls save.image in the current working directory and copys the resulting .RData file to the container's working directory. The created file in the local working director will not be deleted. Alternatively, you can pass a list of objects to be saved, which may also include arguments to be passed down to save, e.g. save_image = list("object1", "object2"). You can configure the name of the file the objects are saved to by adding a file name to the list of arguments, e.g. save_image = list("objectA", save_image_filename = "mydata.RData"), in which case the file path must be in UNIX notation. Note that you may not use save_image_filename for other objects in your session! save will be called with envir.

envir

The environment for save_image.

env

optionally specify environment variables to be included in the image. See documentation: 'https://docs.docker.com/engine/reference/builder/#env

soft

(boolean) Whether to include soft dependencies when system dependencies are installed, default is no.

offline

(boolean) Whether to use an online database to detect system dependencies or use local package information (slower!), default is no.

copy

whether and how a workspace should be copied - values: "script", "script_dir" or a list of relative file paths to be copied, or NA ot disable copying of files

container_workdir

the working directory in the container, defaults to /payload/ and must end with /. Can be skipped with value NULL.

cmd

The CMD statement that should be executed by default when running a parameter. Use CMD_Rscript(path) in order to reference an R script to be executed on startup, CMD_Render(path) to render an R Markdown document, or Cmd(command) for any command. If character is provided it is passed wrapped in a Cmd(command).

entrypoint

the ENTRYPOINT statement for the Dockerfile

add_self

Whether to add the package containerit itself if loaded/attached to the session

silent

Whether or not to print information during execution

predetect

Extract the required libraries based on library calls using the package automagic before running a script/document

versioned_libs

[EXPERIMENTAL] Whether it shall be attempted to match versions of linked external libraries

versioned_packages

Whether it shall be attempted to match versions of R packages

filter_baseimage_pkgs

Do not add packages from CRAN that are already installed in the base image. This does not apply to non-CRAN dependencies, e.g. packages install from GitHub.

Value

An object of class Dockerfile

Based on sessionInfo

Use the current sessionInfo) to create a Dockerfile.

Based on a workspace/directory

Given an existing path to a directory, the method tries to automatically find the main R file within that directory. Files are searched recursively. The following types are supported:

  1. regular R script files, identified by file names ending in .R

  2. weaved documents, identified by file names ending in R Markdown (.Rmd)

After identifying the main file, the process continues as described in the section file. If both types are found, documents are given priority over scripts. If multiple files are found, the first file as returned by dir will be used.

Based on a file

Given an executable R script or document, create a Dockerfile to execute this file. This executes the whole file to obtain a complete sessionInfo object, see section "Based on sessionInfo", and copies required files and documents into the container.

Aliases
  • dockerfile
Examples
# NOT RUN {
dockerfile <- dockerfile()
print(dockerfile)

# }
Documentation reproduced from package containerit, version 0.6.0, License: GPL-3 + file LICENSE

Community examples

Looks like there are no examples yet.