render_docker.Rd 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. % Generated by roxygen2: do not edit by hand
  2. % Please edit documentation in R/render_docker.R
  3. \name{render_docker}
  4. \alias{render_docker}
  5. \alias{drender}
  6. \title{Render Containerized R Markdown Documents}
  7. \usage{
  8. render_docker(input = NULL, tag = NULL, container_name = NULL,
  9. cache = TRUE, build_args = NULL, run_args = NULL, prune = TRUE,
  10. prune_info = TRUE, ...)
  11. drender(...)
  12. }
  13. \arguments{
  14. \item{input}{Input file to render in Docker container.}
  15. \item{tag}{Docker image name to build, sent as docker argument \code{-t}.
  16. If not specified, it will use the same name as the input file.}
  17. \item{container_name}{Docker container name to run.
  18. If not specified, will use a randomly generated name.}
  19. \item{cache}{Logical. Controls the \code{--no-cache} argument
  20. in \code{docker run}. Setting this to be \code{TRUE} can accelerate
  21. the rendering speed substantially for repeated/interactive rendering
  22. since the Docker image layers will be cached, with only the changed
  23. (knitr related) image layer being updated. Default is \code{TRUE}.}
  24. \item{build_args}{A character string specifying additional
  25. \code{docker build} arguments. For example,
  26. \code{--pull=true -m="1024m" --memory-swap="-1"}.}
  27. \item{run_args}{A character string specifying additional
  28. \code{docker run} arguments. For example, \code{--privileged=true}.}
  29. \item{prune}{Logical. Should we clean up all dangling containers,
  30. volumes, networks, and images in case the rendering was not successful?
  31. Default is \code{TRUE}.}
  32. \item{prune_info}{Logical. Should we save the Docker container and
  33. image information to a YAML file (name ended with \code{.docker.yml})
  34. for manual pruning or inspections later? Default is \code{TRUE}.}
  35. \item{...}{Additional arguments passed to
  36. \code{\link[rmarkdown]{render}}.}
  37. }
  38. \value{
  39. \itemize{
  40. \item A list containing the image name, container name,
  41. and Docker commands will be returned.
  42. \item An YAML file ending with \code{.docker.yml} storing the
  43. image name, container name, and Docker commands for rendering
  44. this document will be written to the directory of the input file.
  45. \item The rendered output will be written to the directory of the
  46. input file.
  47. }
  48. }
  49. \description{
  50. Render R Markdown documents using Docker.
  51. }
  52. \details{
  53. Before using this function, please run \code{\link{lift}} on the
  54. RMD document first to generate the \code{Dockerfile}.
  55. After a successful rendering, you will be able to clean up the
  56. Docker image with \code{\link{prune_image}}.
  57. Please see \code{vignette('liftr-intro')} for details of the extended
  58. YAML metadata format and system requirements for writing and rendering
  59. containerized R Markdown documents.
  60. }
  61. \examples{
  62. # copy example file
  63. dir_example = paste0(tempdir(), "/liftr-tidyverse/")
  64. dir.create(dir_example)
  65. file.copy(system.file("examples/liftr-tidyverse.Rmd", package = "liftr"), dir_example)
  66. # containerization
  67. input = paste0(dir_example, "liftr-tidyverse.Rmd")
  68. lift(input)
  69. \dontrun{
  70. # render the document with Docker
  71. render_docker(input)
  72. # view rendered document
  73. browseURL(paste0(dir_example, "liftr-tidyverse.pdf"))
  74. # remove the generated Docker image
  75. prune_image(paste0(dir_example, "liftr-tidyverse.docker.yml"))}
  76. }