render_docker.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <!-- Generated by pkgdown: do not edit by hand -->
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <title>Render Containerized R Markdown Documents — render_docker • liftr</title>
  9. <!-- jquery -->
  10. <script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha384-nrOSfDHtoPMzJHjVTdCopGqIqeYETSXhZDFyniQ8ZHcVy08QesyHcnOUpMpqnmWq" crossorigin="anonymous"></script>
  11. <!-- Bootstrap -->
  12. <link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.7/flatly/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
  13. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  14. <!-- Font Awesome icons -->
  15. <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-T8Gy5hrqNKT+hzMclPo118YTQO6cYprQmhrYwIiQ/3axmI1hQomh7Ud2hPOy8SP1" crossorigin="anonymous">
  16. <!-- pkgdown -->
  17. <link href="../pkgdown.css" rel="stylesheet">
  18. <script src="../jquery.sticky-kit.min.js"></script>
  19. <script src="../pkgdown.js"></script>
  20. <!-- mathjax -->
  21. <script src='https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>
  22. <!--[if lt IE 9]>
  23. <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  24. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  25. <![endif]-->
  26. <!-- Google analytics -->
  27. <script>
  28. (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  29. (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  30. m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  31. })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  32. ga('create', 'UA-65001771-1', 'auto');
  33. ga('send', 'pageview');
  34. </script>
  35. </head>
  36. <body>
  37. <div class="container template-reference-topic">
  38. <header>
  39. <div class="navbar navbar-default navbar-fixed-top" role="navigation">
  40. <div class="container">
  41. <div class="navbar-header">
  42. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar">
  43. <span class="icon-bar"></span>
  44. <span class="icon-bar"></span>
  45. <span class="icon-bar"></span>
  46. </button>
  47. <a class="navbar-brand" href="../index.html">liftr</a>
  48. </div>
  49. <div id="navbar" class="navbar-collapse collapse">
  50. <ul class="nav navbar-nav">
  51. <li>
  52. <a href="../index.html">
  53. <span class="fa fa-home fa-lg"></span>
  54. </a>
  55. </li>
  56. <li>
  57. <a href="../reference/index.html">Reference</a>
  58. </li>
  59. <li class="dropdown">
  60. <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
  61. Articles
  62. <span class="caret"></span>
  63. </a>
  64. <ul class="dropdown-menu" role="menu">
  65. <li>
  66. <a href="../articles/liftr-addins.html">RStudio Addins for liftr</a>
  67. </li>
  68. <li>
  69. <a href="../articles/liftr-intro.html">A Quick Introduction to liftr</a>
  70. </li>
  71. <li>
  72. <a href="../articles/liftr-tidyverse.html">Explore tidyverse with liftr</a>
  73. </li>
  74. </ul>
  75. </li>
  76. <li>
  77. <a href="../news/index.html">News</a>
  78. </li>
  79. </ul>
  80. <ul class="nav navbar-nav navbar-right">
  81. <li>
  82. <a href="https://github.com/road2stat/liftr">
  83. <span class="fa fa-github fa-lg"></span>
  84. </a>
  85. </li>
  86. </ul>
  87. </div><!--/.nav-collapse -->
  88. </div><!--/.container -->
  89. </div><!--/.navbar -->
  90. </header>
  91. <div class="row">
  92. <div class="col-md-9 contents">
  93. <div class="page-header">
  94. <h1>Render Containerized R Markdown Documents</h1>
  95. </div>
  96. <p>Render R Markdown documents using Docker.</p>
  97. <pre class="usage"><span class='fu'>render_docker</span>(<span class='kw'>input</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>tag</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>container_name</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
  98. <span class='kw'>cache</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='kw'>build_args</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>run_args</span> <span class='kw'>=</span> <span class='kw'>NULL</span>, <span class='kw'>prune</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
  99. <span class='kw'>prune_info</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>, <span class='no'>...</span>)
  100. <span class='fu'>drender</span>(<span class='no'>...</span>)</pre>
  101. <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a> Arguments</h2>
  102. <table class="ref-arguments">
  103. <colgroup><col class="name" /><col class="desc" /></colgroup>
  104. <tr>
  105. <th>input</th>
  106. <td><p>Input file to render in Docker container.</p></td>
  107. </tr>
  108. <tr>
  109. <th>tag</th>
  110. <td><p>Docker image name to build, sent as docker argument <code>-t</code>.
  111. If not specified, it will use the same name as the input file.</p></td>
  112. </tr>
  113. <tr>
  114. <th>container_name</th>
  115. <td><p>Docker container name to run.
  116. If not specified, will use a randomly generated name.</p></td>
  117. </tr>
  118. <tr>
  119. <th>cache</th>
  120. <td><p>Logical. Controls the <code>--no-cache</code> argument
  121. in <code>docker run</code>. Setting this to be <code>TRUE</code> can accelerate
  122. the rendering speed substantially for repeated/interactive rendering
  123. since the Docker image layers will be cached, with only the changed
  124. (knitr related) image layer being updated. Default is <code>TRUE</code>.</p></td>
  125. </tr>
  126. <tr>
  127. <th>build_args</th>
  128. <td><p>A character string specifying additional
  129. <code>docker build</code> arguments. For example,
  130. <code>--pull=true -m="1024m" --memory-swap="-1"</code>.</p></td>
  131. </tr>
  132. <tr>
  133. <th>run_args</th>
  134. <td><p>A character string specifying additional
  135. <code>docker run</code> arguments. For example, <code>--privileged=true</code>.</p></td>
  136. </tr>
  137. <tr>
  138. <th>prune</th>
  139. <td><p>Logical. Should we clean up all dangling containers,
  140. volumes, networks, and images in case the rendering was not successful?
  141. Default is <code>TRUE</code>.</p></td>
  142. </tr>
  143. <tr>
  144. <th>prune_info</th>
  145. <td><p>Logical. Should we save the Docker container and
  146. image information to a YAML file (name ended with <code>.docker.yml</code>)
  147. for manual pruning or inspections later? Default is <code>TRUE</code>.</p></td>
  148. </tr>
  149. <tr>
  150. <th>...</th>
  151. <td><p>Additional arguments passed to
  152. <code><a href='http://www.rdocumentation.org/packages/rmarkdown/topics/render'>render</a></code>.</p></td>
  153. </tr>
  154. </table>
  155. <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
  156. <ul>
  157. <li><p>A list containing the image name, container name,
  158. and Docker commands will be returned.</p></li>
  159. <li><p>An YAML file ending with <code>.docker.yml</code> storing the
  160. image name, container name, and Docker commands for rendering
  161. this document will be written to the directory of the input file.</p></li>
  162. <li><p>The rendered output will be written to the directory of the
  163. input file.</p></li>
  164. </ul>
  165. <h2 class="hasAnchor" id="details"><a class="anchor" href="#details"></a>Details</h2>
  166. <p>Before using this function, please run <code><a href='lift.html'>lift</a></code> on the
  167. RMD document first to generate the <code>Dockerfile</code>.</p>
  168. <p>After a successful rendering, you will be able to clean up the
  169. Docker image with <code><a href='prune_image.html'>prune_image</a></code>.</p>
  170. <p>Please see <code><a href='../articles/liftr-intro.html'>vignette('liftr-intro')</a></code> for details of the extended
  171. YAML metadata format and system requirements for writing and rendering
  172. containerized R Markdown documents.</p>
  173. <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
  174. <pre class="examples"><div class='input'><span class='co'># copy example file</span>
  175. <span class='no'>dir_example</span> <span class='kw'>=</span> <span class='fu'>paste0</span>(<span class='fu'>tempdir</span>(), <span class='st'>"/liftr-tidyverse/"</span>)
  176. <span class='fu'>dir.create</span>(<span class='no'>dir_example</span>)
  177. <span class='fu'>file.copy</span>(<span class='fu'>system.file</span>(<span class='st'>"examples/liftr-tidyverse.Rmd"</span>, <span class='kw'>package</span> <span class='kw'>=</span> <span class='st'>"liftr"</span>), <span class='no'>dir_example</span>)</div><div class='output co'>#&gt; [1] TRUE</div><div class='input'>
  178. <span class='co'># containerization</span>
  179. <span class='no'>input</span> <span class='kw'>=</span> <span class='fu'>paste0</span>(<span class='no'>dir_example</span>, <span class='st'>"liftr-tidyverse.Rmd"</span>)
  180. <span class='fu'><a href='lift.html'>lift</a></span>(<span class='no'>input</span>)</div><span class='co'># NOT RUN {</span>
  181. <span class='co'># render the document with Docker</span>
  182. <span class='fu'>render_docker</span>(<span class='no'>input</span>)
  183. <span class='co'># view rendered document</span>
  184. <span class='fu'>browseURL</span>(<span class='fu'>paste0</span>(<span class='no'>dir_example</span>, <span class='st'>"liftr-tidyverse.pdf"</span>))
  185. <span class='co'># remove the generated Docker image</span>
  186. <span class='fu'><a href='prune_image.html'>prune_image</a></span>(<span class='fu'>paste0</span>(<span class='no'>dir_example</span>, <span class='st'>"liftr-tidyverse.docker.yml"</span>))
  187. <span class='co'># }</span></pre>
  188. </div>
  189. <div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
  190. <h2>Contents</h2>
  191. <ul class="nav nav-pills nav-stacked">
  192. <li><a href="#arguments">Arguments</a></li>
  193. <li><a href="#value">Value</a></li>
  194. <li><a href="#details">Details</a></li>
  195. <li><a href="#examples">Examples</a></li>
  196. </ul>
  197. </div>
  198. </div>
  199. <footer>
  200. <div class="copyright">
  201. <p>Developed by Nan Xiao.</p>
  202. </div>
  203. <div class="pkgdown">
  204. <p>Site built with <a href="http://hadley.github.io/pkgdown/">pkgdown</a>.</p>
  205. </div>
  206. </footer>
  207. </div>
  208. </body>
  209. </html>