-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
313 lines (221 loc) · 10.5 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
---
output:
github_document
---
<!-- README.md is generated from README.Rmd. Please edit README.Rmd file and render to .md with
rmarkdown::render(input = "README.Rmd")
-->
```{r setup, include = FALSE, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
results = "asis",
echo = TRUE,
comment = "#>")
date <- format(Sys.time(), "%b %d, %Y")
```
# Welcome to DateLife's Docker GitHub repository!
![Docker Pulls](https://img.shields.io/docker/pulls/lunasare/datelife?color=green)
<!--![Docker Cloud Build Status](https://img.shields.io/docker/cloud/build/bomeara/datelife)-->
![Docker Automated build](https://img.shields.io/docker/automated/lunasare/datelife?color=green)
[![NSF-1458603](https://img.shields.io/badge/NSF-1458603-blue.svg)](https://nsf.gov/awardsearch/showAward?AWD_ID=1458603)
[![NSF-0905606](https://img.shields.io/badge/NSF-0905606-blue.svg)](https://nsf.gov/awardsearch/showAward?AWD_ID=0905606)
[![NSF-1458572](https://img.shields.io/badge/NSF-1458572-blue.svg)](https://nsf.gov/awardsearch/showAward?AWD_ID=1458572)
`datelife` is a software that gets all available information on time of divergence of a group of lineages, and uses this information to date a phylogenetic tree.
Its functionalities can be accessed via the [`datelife` R package](https://github.com/phylotastic/datelife), or through [`datelife`'s website](http://datelife.opentreeoflife.org/query), which is [constructed as an R shiny application](https://github.com/phylotastic/datelifeweb) and is containerized with [Docker](https://www.docker.com/?utm_source=google&utm_medium=cpc&utm_campaign=dockerhomepage&utm_content=namer&utm_term=dockerhomepage&utm_budget=growth&gclid=CjwKCAjw7--KBhAMEiwAxfpkWMXM6XbTANoSspqojqsXX7dBeTm13Yc7lwzn8kz7iAWAT_m0fEo9MRoCq9MQAvD_BwE), i.e. "dockerized", as [explained here](https://www.r-bloggers.com/2021/05/dockerizing-shiny-applications/).
This repository hosts the instructions for "dockerizing" `datelife`, which we whipped up by following diverse [valuable resources](#resources). The `datelife` Docker allows anyone to set up their own server for the `datelife` web app anywhere.
There are a few alternative ways to do this. For all of them you require [Docker Desktop installed](https://www.docker.com/products/docker-desktop).
Table of Contents:
[1. Setting up a prebuilt `datelife` image](#1-using-a-prebuilt-datelife-docker-image)
[  • Docker image datelife v0.5.0 about](#docker-image-datelife-v050-about)
[2. Building a local `datelife` image](#2-building-your-own-datelife-docker-image)
[3. Running multiple instances of the `datelife` shiny app](#3-running-multiple-instances)
[4. Using swarm](#4-swarm)
[Resources](#resources)
<br><br>
## 1. Using a prebuilt DateLife Docker image
Ideally, the latest `datelife` Docker image automatically builds and uploads to [bomeara/datelife's Docker Hub (the Docker cloud)](https://hub.docker.com/r/bomeara/datelife/dockerfile) with pushes to [this repository (the GitHub phylotastic/datelifedocker repo)](https://github.com/phylotastic/datelifedocker). However, due to changes on Docker's product subscriptions, automatic builds are not available for the moment (last updated on `r date`). `datelife v0.5.0` is the latest, locally built, manually uploaded Docker image, and is hosted at [lunasare/datelife's Docker Hub](https://hub.docker.com/repository/docker/lunasare/datelife).
<!-- Look at this for list styling: https://gist.github.com/bertobox/3503850#gistcomment-1213320 -->
<ul style="list-style-type:none;">
<li> 1.1. To download the prebuilt <code>datelife</code> Docker image from Docker Hub you need <a href="https://www.docker.com/products/docker-desktop">Docker desktop installed</a>. Then, from terminal use the <code>docker pull</code> command:
</li><br>
```shell
# docker pull bomeara/datelife
docker pull lunasare/datelife:v0.5.0
```
<li> 1.2. Now, you can start the image using <code>docker run</code>. You can do this in "bash mode" so you can look around (i.e., in the /srv dir for the shiny app):
</li><br>
```shell
# docker run -t -i -p 80:3838 bomeara/datelife sh -c '/bin/bash'
docker run -t -i -p 80:3838 lunasare/datelife:v0.5.0 sh -c '/bin/bash'
```
Once you've finished looking around, just type `exit` and you will be logged out.
<li> 1.3. To start the image just in serve mode, do:
</li><br>
```shell
# docker run -t -i -d -p 80:3838 bomeara/datelife
docker run -t -i -d -p 80:3838 lunasare/datelife:v0.5.0
```
Go to http://localhost on any browser to checkout your Datelife website and shiny app running.
Argument `-d` is optional, it stands for `--detach`, allowing you to keep on using your terminal while the DateLife website is being served.
</ul>
### Docker image datelife v0.5.0 about
<details>
<summary>Information on R packages used</summary>
Obtained with R by running the following from the [datelifeweb](https://github.com/phylotastic/datelifeweb) project in RStudio:
```r
renv::init()
deps <- unique(renv::dependencies()[,"Package"])
vers <- structure(lapply(deps[order(deps)], packageVersion), names = deps[order(deps)])
vers
```
```
$ape
[1] ‘5.5’
$datelife
[1] ‘0.5.0’
$datelifeplot
[1] ‘0.1.0’
$devtools
[1] ‘2.4.2’
$future
[1] ‘1.22.1’
$phangorn
[1] ‘2.7.1’
$phyloch
[1] ‘1.5.5’
$promises
[1] ‘1.2.0.1’
$renv
[1] ‘0.14.0’
$shiny
[1] ‘1.6.0’
$shinycssloaders
[1] ‘1.0.0’
$strap
[1] ‘1.4’
$stringr
[1] ‘1.4.0’
$utils
[1] ‘4.1.0’
```
</details>
<details>
<summary>Information on Docker software</summary>
Obtained with <code>docker version</code> command from the terminal:
```shell
Client: Docker Engine - Community
Cloud integration: 1.0.7
Version: 20.10.2
API version: 1.41
Go version: go1.13.15
Git commit: 2291f61
Built: Mon Dec 28 16:12:42 2020
OS/Arch: darwin/amd64
Context: default
Experimental: true
Server: Docker Engine - Community
Engine:
Version: 20.10.2
API version: 1.41 (minimum version 1.12)
Go version: go1.13.15
Git commit: 8891c58
Built: Mon Dec 28 16:15:28 2020
OS/Arch: linux/amd64
Experimental: true
containerd:
Version: 1.4.3
GitCommit: 269548fa27e0089a8b8278fc4fc781d7f65a939b
runc:
Version: 1.0.0-rc92
GitCommit: ff819c7e9184c13b7c2607fe6c30ae19403a7aff
docker-init:
Version: 0.19.0
GitCommit: de40ad0
```
</details>
<br><br>
## 2. Building your own DateLife Docker image
This is the option for developers, and local debugging. If you tried setting up a prebuilt Docker image and it fails, you should try this.
<ul style="list-style-type:none;">
<li> 2.1. Make sure you have <a href="https://www.docker.com/products/docker-desktop">Docker desktop installed</a>. Then, download the <a href="https://github.com/phylotastic/datelifedocker">datelifedocker repository</a> to your computer. One way is to type from the terminal:
</li><br>
```shell
git clone https://github.com/phylotastic/datelifedocker.git
```
<li> 2.2. Change directories to your newly created datelifedocker directory using <code>cd your_path/datelifedocker</code>, and build the DateLife Docker image with:
</li><br>
```shell
docker build -t datelife:[optional tag] .
```
To build with _no cache_ (that is, rebuilding the image from scratch)
type `docker build -t datelife --no-cache .`
Note! Building with _no cache_ will take about **2hrs and 36 min** to run.
<li> 2.3 Now you can start the DateLife server from your newly created Docker image with:
</li><br>
```shell
docker run -t -i -p 80:3838 datelife:[optional tag]
```
Go to http://localhost on any browser to checkout your Datelife shiny app running.
To stop serving, type `Ctrl + c` or `exit`
<li> 2.4. To explore the contents of the DateLife Docker image on terminal, you can do:
</li><br>
```shell
docker run -t -i datelife:[optional tag] sh -c '/bin/bash'
```
If you want to explore a particular container, first list them all with `docker container ls`, and identify the `container-name` of the one you are interested in.
Then restart your container and execute it with:
```shell
docker container restart <container-name>
docker exec -it <container-name> sh -c '/bin/bash'
```
For more tips see [how-do-i-get-into-a-docker-containers-shell](https://stackoverflow.com/questions/30172605/how-do-i-get-into-a-docker-containers-shell)
and [15-docker-commands-you-should-know](https://towardsdatascience.com/15-docker-commands-you-should-know-970ea5203421).
<li> 2.5. After building and making changes, you can push (if you have permissions) the new <code>datelife</code> Docker image to Docker hub with:
</li><br>
```shell
docker tag datelife:[version number] lunasare/datelife:[version number]
docker login
docker push lunasare/datelife:[version number]
```
Note! If you make any important changes to the `dockerfile`, please bump its version and
document the changes on the section [Docker image DateLife](#docker-image-datelife-v050-about) of this README.
</ul>
<br><br>
## 3. Running multiple instances
You can run multiple shiny app instances with:
```shell
docker-compose up -d --scale datelife=10 # for ten instances
```
<br><br>
## 4. Swarm
<ul style="list-style-type:none;">
<li> 4.1. Go to node where swarm is being managed. You can change the number of workers in replicas in the <code>docker-compose-swarm.yml</code> file.
</li><br>
```shell
sudo docker stack deploy --compose-file docker-compose-swarm.yml datelife
```
<li> 4.2. See how it's doing with
</li><br>
```shell
sudo docker stack services datelife
```
<li> 4.3. And stop it with
</li><br>
```shell
sudo docker stack rm datelife
```
For domain, *, @, www all resolve to `datelife19.campus.utk.edu.` (yes, with a period after edu) using CNAME
</ul>
<br><br>
## Resources
- https://www.r-bloggers.com/2021/05/dockerizing-shiny-applications/
- https://github.com/flaviobarros/shiny-wordcloud/blob/master/Dockerfile
- https://www.statworx.com/at/blog/how-to-dockerize-shinyapps/
- https://www.youtube.com/watch?v=ARd5IldVFUs
- https://hub.docker.com/u/rocker
- https://www.dabbleofdevops.com/blog/deploy-rshiny-with-the-rocker-shiny-docker-image
- https://blog.sellorm.com/2021/04/25/shiny-app-in-docker/
- https://juanitorduz.github.io/dockerize-a-shinyapp/
- https://bhoom.wordpress.com/2020/06/18/using-multiple-r-versions-with-docker-rocker-rstudio-project/
- https://githubmemory.com/repo/rocker-org/shiny/issues/92
- https://stackoverflow.com/questions/30172605/how-do-i-get-into-a-docker-containers-shell