use_docker {pracpac} | R Documentation |
Use docker packaging tools
Description
Wrapper function around other pracpac
functions. See help for the functions linked below for detail on individual functions.
All arguments to use_docker()
are passed to downstream functions. use_docker()
will sequentially run:
-
pkg_info to get information about the current R package.
-
create_docker_dir to create the
docker/
directory in the specified location, if it doesn't already exist. -
renv_deps (if
use_renv=TRUE
, the default) to capture package dependencies with renv and create anrenv.lock
file -
add_dockerfile to create a Dockerfile using template specified by
use_case
-
add_assets depending on the
use_case
-
build_pkg to build the current R package source .tar.gz, and place it into the
docker/
directory -
build_image optional, default
FALSE
; if TRUE, will build the Docker image.
The default build=FALSE
means that everything up to build_image()
is run,
but the image is not actually built. Instead, use_docker()
will message the
docker build
command, and return that string in $buildcmd
in the
invisibly returned output.
See vignette("use-cases", package="pracpac")
for details on use cases.
Usage
use_docker(
pkg_path = ".",
img_path = NULL,
use_renv = TRUE,
use_case = "default",
base_image = NULL,
other_packages = NULL,
build = FALSE,
repos = NULL,
overwrite_assets = TRUE,
overwrite_renv = TRUE,
consent_renv = TRUE
)
Arguments
pkg_path |
Path to the package directory. Default is |
img_path |
Path to the write the docker image definition contents. The default |
use_renv |
Logical; use renv? Defaults to |
use_case |
Name of the use case. Defaults to |
base_image |
Name of the base image to start |
other_packages |
Vector of other packages to be included in |
build |
Logical as to whether or not the image should be built. Default is |
repos |
Option to override the repos used for installing packages with |
overwrite_assets |
Logical; should existing asset files should be overwritten? Default is |
overwrite_renv |
Logical; should an existing lock file should be overwritten? Default is |
consent_renv |
Logical; give renv consent in this session with |
Value
Invisibly returns a list with information about the package ($info
) and
the docker build
command ($buildcmd
). Primarily called for side effect.
Creates docker/
directory, identifies renv dependencies and creates lock
file (if use_renv = TRUE
), writes Dockerfile, builds package tar.gz,
moves all relevant assets to the docker/
directory, and builds Docker
image (if build = TRUE
).
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"))
# To not use renv
use_docker(pkg_path = file.path(tempdir(), "hellow"), use_renv=FALSE)
# To specify a use case
use_docker(pkg_path = file.path(tempdir(), "hellow"), use_case="pipeline")
# To overwrite the default base image
use_docker(pkg_path = file.path(tempdir(), "hellow"), base_image="alpine:latest")
## End(Not run)