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
NULLwill usedocker/as a subdirectory of thepkg_path.- cache
Logical; should caching be used? Default
TRUE. Set toFALSEto use--no-cacheindocker build.- tag
Image tag to use; default is
NULLand 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 ifFALSEthedocker buildcommand will be messaged. Settingbuild=FALSEcould be useful if additionaldocker buildoptions or different tags are desired. In either case thedocker buildcommand 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
}
