build_image {pracpac}R Documentation

Build a Docker image

Description

Builds a Docker image created by use_docker or add_dockerfile. This function is run as part of use_docker when build = TRUE is set, but can be used on its own.

Usage

build_image(
  pkg_path = ".",
  img_path = NULL,
  cache = TRUE,
  tag = NULL,
  build = TRUE
)

Arguments

pkg_path

Path to the package directory. Default is "." for the current working directory, which assumes developer is working in R package root. However, this can be set to another path as needed.

img_path

Path to the write the docker image definition contents. The default NULL will use ⁠docker/⁠ as a subdirectory of the pkg_path.

cache

Logical; should caching be used? Default TRUE. Set to FALSE to use --no-cache in ⁠docker build⁠.

tag

Image tag to use; default is NULL and the image will be tagged with package name version from pkg_info.

build

Logical as to whether or not the image should be built. Default is TRUE, and if FALSE the ⁠docker build⁠ command will be messaged. Setting build=FALSE could be useful if additional ⁠docker build⁠ options or different tags are desired. In either case the ⁠docker build⁠ command will be returned invisibly.

Value

Invisibly returns the ⁠docker build⁠ command. Primarily called for its side effects, which runs the ⁠docker build⁠ as a system command.

Examples

## Not run: 
# Specify path to example package source and copy to tempdir()
# Note that in practice you do not need to copy to a tempdir()
# And in fact it may be easiest to use pracpac relative to your package directory root
ex_pkg_src <- system.file("hellow", package = "pracpac", mustWork = TRUE)
file.copy(from = ex_pkg_src, to = tempdir(), recursive = TRUE)

# Run use_docker to create Docker directory and assets for the example package
use_docker(pkg_path = file.path(tempdir(), "hellow"))

# Build the image
build_image(pkg_path = file.path(tempdir(), "hellow"))
# Or construct the image build command without building
build_cmd <- build_image(pkg_path = file.path(tempdir(), "hellow"), build=FALSE)
build_cmd

## End(Not run)

[Package pracpac version 0.2.0 Index]