knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>",
  fig.path = "man/figures/README-",
  out.width = "100%"
)

dockyard

lifecycle Travis build status AppVeyor build status Coverage status

The goal of dockyard is to provide tooling for building and deploying docker containers directly from R. Most best practices suggest using docker to containerize work, but do not provide the instructions on how to do so.

Installation

You can install the released version of dockyard from CRAN with:

# Not true yet
#install.packages("dockyard")

We are only on github at the moment, and can be downloaded at:

install.packages("remotes")
remotes::install_github("thebioengineer/dockyard")

Example

So far, {dockyard} has tooling for creating basic dockerfiles and building from them. Below is an example of building a dockerimage in the same format as the rocker/shiny image.

In this example, the output image is called "dockyard_shiny_example". When printing out the dockerfile object, it may look like some steps were skipped, but rest assured all the steps outlined exist. When RUN statements are listed one after another, they are linked together via &&. This reduces the number of intermediary steps docker goes through when generating our image.

library(dockyard)

shiny_dockerfile <- dockerfile() %>%
 from("rocker/r-ver:devel") %>%
 update() %>%
 install("sudo","gdebi","pandoc","pandoc-citeproc",
         "libcurl4-gnutls-dev","libcairo2-dev",
         "libxt-dev","wget") %>%
  run("wget --no-verbose https://download3.rstudio.org/ubuntu-14.04/x86_64/VERSION -O version.txt") %>%
  run("VERSION=$(cat version.txt)") %>%
  run("wget --no-verbose https://download3.rstudio.org/ubuntu-14.04/x86_64/shiny-server-$VERSION-amd64.deb -O ss-latest.deb") %>%
  run("gdebi -n ss-latest.deb") %>%
  run("rm -f version.txt ss-latest.deb") %>%
  run(". /etc/environment") %>%
  install_r_lib("shiny","rmarkdown") %>%
  run("cp -R /usr/local/lib/R/site-library/shiny/examples/* /srv/shiny-server/") %>%
  expose(3838) %>%
  install("curl") %>% 
  copy_from_url("https://raw.githubusercontent.com/rocker-org/shiny/master/shiny-server.sh","/usr/bin/shiny-server.sh") %>%
  run("chmod +x /usr/bin/shiny-server.sh") %>%
  cmd("/usr/bin/shiny-server.sh") 

shiny_dockerfile
shiny_dockerfile %>% 
  save("shiny_dockerfile",overwrite = TRUE) %>% 
  build("dockyard_shiny_example")

Now to get your newly formed docker image into a docker container and control it, we use docker_run.

docker_conn <- docker_run(
                 image = "dockyard_shiny_example", # the docker image to use
                 name  = "dockyard_container",     # the name to assign to the docker container
                 ports = "3838:3838"               # which port from local to connect to in the container 
                 ) 

docker_conn

To stop the docker container, we use docker_stop

# we can also use the name of the container to stop it
# docker_stop("dockyard_container")
docker_stop(docker_conn)

docker_conn

Code of Conduct

Please note that the 'dockyard' project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.



thebioengineer/dockyard documentation built on Dec. 4, 2019, 1:44 a.m.