Generate files necessary to build a Docker container for a vetiver model
Source:R/write-docker.R
vetiver_prepare_docker.Rd
Deploying a vetiver model via Docker requires several files. Use this
function to create these needed files in the directory located at path
.
Arguments
- board
A pin board, created by
board_folder()
,board_connect()
,board_url()
or anotherboard_
function.- name
Pin name.
- version
Retrieve a specific version of a pin. Use
pin_versions()
to find out which versions are available and when they were created.- path
A path to write the Plumber file, Dockerfile, and lockfile, capturing the model's dependencies.
- predict_args
A list of optional arguments passed to
vetiver_api()
such as the predictiontype
.- docker_args
A list of optional arguments passed to
vetiver_write_docker()
such as thelockfile
name or whether to userspm
. Do not passadditional_pkgs
here, as this function usesadditional_pkgs = required_pkgs(board)
.
Details
The function vetiver_prepare_docker()
uses:
vetiver_write_plumber()
to create a Plumber file andvetiver_write_docker()
to create a Dockerfile and renv lockfile
These modular functions are available for more advanced use cases. For
models such as keras and torch, you will need to edit the generated
Dockerfile to, for example, COPY requirements.txt requirements.txt
or
similar.
Examples
library(pins)
b <- board_temp(versioned = TRUE)
cars_lm <- lm(mpg ~ ., data = mtcars)
v <- vetiver_model(cars_lm, "cars_linear")
vetiver_pin_write(b, v)
#> Creating new version '20231116T230224Z-100cb'
#> Writing to pin 'cars_linear'
vetiver_prepare_docker(b, "cars_linear", path = tempdir())
#> The following package(s) will be updated in the lockfile:
#>
#> # Local ------------------------------------------------------------------
#> - vetiver [* -> 0.2.5]
#>
#> # RSPM -------------------------------------------------------------------
#> - R6 [* -> 2.5.1]
#> - Rcpp [* -> 1.0.11]
#> - askpass [* -> 1.2.0]
#> - bit [* -> 4.0.5]
#> - bit64 [* -> 4.0.5]
#> - bundle [* -> 0.1.1]
#> - butcher [* -> 0.3.3]
#> - cereal [* -> 0.1.0]
#> - cli [* -> 3.6.1]
#> - clipr [* -> 0.8.0]
#> - cpp11 [* -> 0.4.6]
#> - crayon [* -> 1.5.2]
#> - curl [* -> 5.1.0]
#> - digest [* -> 0.6.33]
#> - ellipsis [* -> 0.3.2]
#> - fansi [* -> 1.0.5]
#> - fastmap [* -> 1.1.1]
#> - fs [* -> 1.6.3]
#> - generics [* -> 0.1.3]
#> - glue [* -> 1.6.2]
#> - hardhat [* -> 1.3.0]
#> - hms [* -> 1.1.3]
#> - httpuv [* -> 1.6.12]
#> - httr [* -> 1.4.7]
#> - jsonlite [* -> 1.8.7]
#> - later [* -> 1.3.1]
#> - lifecycle [* -> 1.0.4]
#> - lobstr [* -> 1.1.2]
#> - magrittr [* -> 2.0.3]
#> - mime [* -> 0.12]
#> - openssl [* -> 2.1.1]
#> - pillar [* -> 1.9.0]
#> - pins [* -> 1.3.0]
#> - pkgconfig [* -> 2.0.3]
#> - plumber [* -> 1.2.1]
#> - prettyunits [* -> 1.2.0]
#> - progress [* -> 1.2.2]
#> - promises [* -> 1.2.1]
#> - purrr [* -> 1.0.2]
#> - rapidoc [* -> 8.4.3]
#> - rappdirs [* -> 0.3.3]
#> - readr [* -> 2.1.4]
#> - renv [* -> 1.0.3]
#> - rlang [* -> 1.1.2]
#> - sodium [* -> 1.3.0]
#> - stringi [* -> 1.8.1]
#> - swagger [* -> 3.33.1]
#> - sys [* -> 3.4.2]
#> - tibble [* -> 3.2.1]
#> - tidyselect [* -> 1.2.0]
#> - tzdb [* -> 0.4.0]
#> - utf8 [* -> 1.2.4]
#> - vctrs [* -> 0.6.4]
#> - vroom [* -> 1.6.4]
#> - webutils [* -> 1.1]
#> - whisker [* -> 0.4.1]
#> - withr [* -> 2.5.2]
#> - yaml [* -> 2.3.7]
#>
#> The version of R recorded in the lockfile will be updated:
#> - R [* -> 4.3.2]
#>
#> - Lockfile written to "vetiver_renv.lock".