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.
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 usedocker/
as a subdirectory of thepkg_path
.- cache
Logical; should caching be used? Default
TRUE
. Set toFALSE
to use--no-cache
indocker 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 ifFALSE
thedocker build
command will be messaged. Settingbuild=FALSE
could be useful if additionaldocker build
options or different tags are desired. In either case thedocker 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
if (FALSE) {
# 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
}