% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/write-docker.R
\name{vetiver_write_docker}
\alias{vetiver_write_docker}
\title{Write a Dockerfile for a vetiver model}
\usage{
vetiver_write_docker(
  vetiver_model,
  plumber_file = "plumber.R",
  path = ".",
  ...,
  lockfile = "vetiver_renv.lock",
  rspm = TRUE,
  base_image = glue::glue("FROM rocker/r-ver:{getRversion()}"),
  port = 8000,
  expose = TRUE,
  additional_pkgs = character(0)
)
}
\arguments{
\item{vetiver_model}{A deployable \code{\link[=vetiver_model]{vetiver_model()}} object}

\item{plumber_file}{A path for your Plumber file, created via
\code{\link[=vetiver_write_plumber]{vetiver_write_plumber()}}. Defaults to \code{plumber.R} in the working directory.}

\item{path}{A path to write the Dockerfile and \code{lockfile}, capturing the
model's package dependencies. Defaults to the working directory.}

\item{...}{Not currently used.}

\item{lockfile}{The generated lockfile in \code{path}. Defaults to
\code{"vetiver_renv.lock"}.}

\item{rspm}{A logical to use the
\href{https://packagemanager.rstudio.com/}{RStudio Public Package Manager} for
\code{renv::restore()} in the Docker image. Defaults to \code{TRUE}.}

\item{base_image}{The base Docker image to start with. Defaults to
\code{rocker/r-ver} for the version of R you are working with, but models like
keras will require a different base image.}

\item{port}{The server port for listening: a number such as 8080 or an
expression like \code{'as.numeric(Sys.getenv("PORT"))'} when the port is injected
as an environment variable.}

\item{expose}{Add \code{EXPOSE} to the Dockerfile? This is helpful for using
Docker Desktop but does not work with an expression for \code{port}.}

\item{additional_pkgs}{A character vector of additional package names to add
to the Docker image. For example, some boards like \code{\link[pins:board_s3]{pins::board_s3()}} require
additional software; you can use \code{required_pkgs(board)} here.}
}
\value{
The content of the Dockerfile, invisibly.
}
\description{
After creating a Plumber file with \code{\link[=vetiver_write_plumber]{vetiver_write_plumber()}}, use
\code{vetiver_write_docker()} to create a Dockerfile plus a \code{vetiver_renv.lock}
file for a pinned \code{\link[=vetiver_model]{vetiver_model()}}.
}
\examples{
\dontshow{if (interactive() || identical(Sys.getenv("IN_PKGDOWN"), "true")) withAutoprint(\{ # examplesIf}

library(pins)
tmp_plumber <- tempfile()
b <- board_temp(versioned = TRUE)
cars_lm <- lm(mpg ~ ., data = mtcars)
v <- vetiver_model(cars_lm, "cars_linear")
vetiver_pin_write(b, v)
vetiver_write_plumber(b, "cars_linear", file = tmp_plumber)

## default port
vetiver_write_docker(v, tmp_plumber, tempdir())
## install more pkgs, like those required to access board
vetiver_write_docker(v, tmp_plumber, tempdir(),
                     additional_pkgs = required_pkgs(b))
## port from env variable
vetiver_write_docker(v, tmp_plumber, tempdir(),
                     port = 'as.numeric(Sys.getenv("PORT"))',
                     expose = FALSE)
\dontshow{\}) # examplesIf}
}
