add_dockerfile {pracpac} | R Documentation |
Add a Dockerfile to the docker directory
Description
Adds a Dockerfile to the docker directory created by create_docker_dir. Allows for specification of several preset use cases, whether or not use use renv to manage dependencies, and optional overriding the base image.
Usage
add_dockerfile(
pkg_path = ".",
img_path = NULL,
use_renv = TRUE,
use_case = "default",
base_image = NULL,
repos = NULL
)
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 |
repos |
Option to override the repos used for installing packages with |
Details
This function is run as part of use_docker but can be used on its own.
See vignette("use-cases", package="pracpac")
for details on use cases.
Value
Invisibly returns a list of package info returned by pkg_info. Primarily called for side-effect to create Dockerfile.
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)
# Default: FROM rocker/r-ver:latest with no additional template
# By default add_dockerfile requires you either to specify use_renv = FALSE
# Or run renv_deps() prior to add_dockerfile()
# The use_docker() wrapper runs these sequentially, and is recommended for most usage
add_dockerfile(pkg_path = file.path(tempdir(), "hellow"), use_renv = FALSE)
# Specify tidyverse base image
renv_deps(pkg_path = file.path(tempdir(), "hellow"))
add_dockerfile(pkg_path = file.path(tempdir(), "hellow"), base_image="rocker/tidyverse:4.2.2")
# Specify different default repo
add_dockerfile(pkg_path = file.path(tempdir(), "hellow"), repos="https://cran.wustl.edu/")
# RStudio template
add_dockerfile(pkg_path = file.path(tempdir(), "hellow"), use_case="rstudio")
# Shiny template
add_dockerfile(pkg_path = file.path(tempdir(), "hellow"), use_case = "shiny")
# Pipeline template
add_dockerfile(pkg_path = file.path(tempdir(), "hellow"), use_case="pipeline")
## End(Not run)