-
Notifications
You must be signed in to change notification settings - Fork 4
/
README.Rmd
114 lines (84 loc) · 3.97 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# dockyard
[![lifecycle](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://www.tidyverse.org/lifecycle/#experimental)
[![Travis build status](https://travis-ci.org/thebioengineer/dockyard.svg?branch=master)](https://travis-ci.org/thebioengineer/dockyard)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/thebioengineer/dockyard?branch=master&svg=true)](https://ci.appveyor.com/project/thebioengineer/dockyard)
[![Coverage status](https://codecov.io/gh/thebioengineer/dockyard/branch/master/graph/badge.svg)](https://codecov.io/github/thebioengineer/dockyard?branch=master)
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](https://CRAN.R-project.org) with:_
``` r
# Not true yet
#install.packages("dockyard")
```
We are only on github at the moment, and can be downloaded at:
``` r
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](https://hub.docker.com/r/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.
```{r example, eval=TRUE}
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
```
```{r eval=FALSE}
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`.
```{r}
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`
```{r}
# 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](CODE_OF_CONDUCT.md). By contributing to this project, you agree to abide by its terms.