@@ -22,27 +22,30 @@ environments or projects.
22
22
## Version-stable deployments
23
23
24
24
When deploying R applications (e.g. a Shiny app) using Docker containers, it is
25
- important to control versioning of R and packages for the sake of reproducibilty
25
+ important to control versioning of R and packages for the sake of reproducibility
26
26
and stability of the deployments. For this reason,
27
- [ version-stable] ( https://github.com/rocker-org/rocker-versioned ) images are
27
+ [ version-stable] ( https://github.com/rocker-org/rocker-versioned2 ) images are
28
28
provided as part of the [ Rocker project] ( https://www.rocker-project.org/ ) and
29
29
used as a basis for deploying productive applications.
30
30
31
31
Each version-stable Rocker image has an associated _ tag_ for all non-latest R
32
- versions (e.g. ` rocker/r-ver:3.6.1 ` ). Besides being specific to the
32
+ versions (e.g. ` rocker/r-ver:4.3.2 ` ). Besides being specific to the
33
33
corresponding version of R, each tag fixes the version of contributed packages
34
- (by using as package repository the MRAN snapshot of the last day CRAN
34
+ (by using as package repository the CRAN snapshot of the last day CRAN
35
35
distributed that R version as latest release). See
36
- [ VERSIONS.md] ( https://github.com/rocker-org/rocker-versioned/blob/master/VERSIONS.md )
36
+ [ wiki/Versions] ( https://github.com/rocker-org/rocker-versioned2/wiki/Versions ) .
37
+ If that R version is the latest, the CRAN date will not be set and the latest packages will always be installed.
38
+
37
39
38
40
The ` Dockerfile ` of a deployed application then defines a given version-stable
39
41
image tag to start ` FROM ` , e.g.
40
42
``` dockerfile
41
- FROM rocker/r-ver:3.6.1
43
+ FROM rocker/r-ver:4.3.2
42
44
```
43
45
See
44
46
[ SmaRP/Dockerfile] ( https://github.com/miraisolutions/SmaRP/blob/master/Dockerfile )
45
47
for an example.
48
+ <!-- NOTE: Not yet merged into master -->
46
49
47
50
48
51
## Align local development and deployment environments
@@ -57,7 +60,7 @@ The idea is then to rely on the same version-stable rocker containers used for
57
60
the deployments, using a containerized versioned RStudio instance for the local
58
61
development. This is available through Rocker's [ versioned
59
62
stack] ( https://www.rocker-project.org/images/#the-versioned-stack ) , so we could
60
- use e.g. ` rocker/rstudio:3.6.1 ` .
63
+ use e.g. ` rocker/rstudio:4.3.2 ` .
61
64
62
65
Note that the same version-stable instance of RStudio can be used across all
63
66
different projects for which such version is relevant. For this reason, a
@@ -69,12 +72,12 @@ install. See the specific section below about 'TinyTeX considerations'.
69
72
70
73
### Running versioned RStudio instances
71
74
72
- Assume we want to run a containerized versioned instance of RStudio for R 3.6.1 ,
75
+ Assume we want to run a containerized versioned instance of RStudio for R 4.3.2 ,
73
76
possibly alongside instances for other versions of R.
74
77
75
78
First of all, we need to get the image from docker-hub
76
79
``` {bash pull}
77
- docker pull rocker/verse:3.6.1
80
+ docker pull rocker/verse:4.3.2
78
81
```
79
82
80
83
We then want to have a running instance on ` localhost ` (` 127.0.0.1 ` ), with the
@@ -83,7 +86,7 @@ following setup:
83
86
- No authentication required (local setup).
84
87
- Enable root by setting the environment variable ` ROOT ` to ` TRUE ` , so that e.g.
85
88
` sudo apt-get ` can be used in RStudio.
86
- - Use a version-specific port, e.g. ` 3500 ` for R 3.5 .0, ` 3610 ` for R 3.6.1 and
89
+ - Use a version-specific port, e.g. ` 4000 ` for R 4.0 .0, ` 4320 ` for R 4.3.2 and
87
90
so on, so that we can use ` localhost ` for concurrent R version instances.
88
91
- The development code of all relevant projects should live outside the
89
92
container and be shared with it (and possibly many of them), e.g. under
@@ -94,19 +97,19 @@ the container.
94
97
the container user (` rstudio ` ) must match the UID of the host user (` $UID ` ).
95
98
- In order for the RStudio setting to persist if the container is recreated
96
99
(e.g. after pulling a new ` rocker ` image), we also use a shared volume (like
97
- ` ~/.rstudio-docker/3.6.1 ` ) for the ` home/rstudio/.rstudio ` directory, which is
100
+ ` ~/.rstudio-docker/4.2.3 ` ) for the ` home/rstudio/.rstudio ` directory, which is
98
101
version-specific in case of multiple R versions
99
102
- If we want to use Meld via the [ compareWith] ( https://github.com/miraisolutions/compareWith/ ) addins, we need to
100
103
- map the ` DISPLAY ` environment variable and volume ` /tmp/.X11-unix `
101
104
- add ` DISPLAY ` to ` Renviron `
102
105
- install Meld
103
106
- install ` dbus-x11 `
104
107
- Use a version-specific name for the container running the RStudio instance,
105
- e.g. ` rstudio_3.6.1 ` .
108
+ e.g. ` rstudio_4.2.3 ` .
106
109
107
110
108
111
``` {bash run}
109
- R_VER=3.6.1
112
+ R_VER=4.3.2
110
113
SHARED_DIR=RStudioProjects
111
114
docker run -d --restart=always \
112
115
-p 127.0.0.1:$(echo $R_VER | sed 's/[.]//g')0:8787 \
@@ -166,19 +169,19 @@ run_rstudio_ver() {
166
169
167
170
which you can re-use as compact command for any R version as follows
168
171
``` {bash run_rstudio_ver-use}
169
- run_rstudio_ver 3.6.1 RStudioProjects
172
+ run_rstudio_ver 4.3.2 RStudioProjects
170
173
```
171
174
172
175
Note that ` --restart=always ` specifies that the container should stay up and restart
173
176
itself after stopping, e.g. upon machine reboot or docker upgrade, so that it is
174
177
always available. Still, you can explicitly stop the running container with
175
178
``` {bash stop}
176
- docker stop rstudio_3.6.1
179
+ docker stop rstudio_4.3.2
177
180
```
178
181
Alternatively, you can omit ` --restart=always ` and explicitly start the
179
182
container whenever needed with
180
183
``` {bash start}
181
- docker start rstudio_3.6.1
184
+ docker start rstudio_4.3.2
182
185
```
183
186
184
187
Note that ` start ` /` stop ` operations do not affect the persistence of files
@@ -213,21 +216,21 @@ If you are using LaTeX and start seeing errors like
213
216
Remote repository is newer than local (2018 < 2019)
214
217
```
215
218
it means that you have to re-install TinyTeX. This happens e.g. with
216
- ` rocker/verse:3.6.1 ` , since it was build at the end of 2018 but the current
219
+ ` rocker/verse:4.3.2 ` , since it was build at the end of 2018 but the current
217
220
Tex Live repo is 2019. You can fix this via a ** user-specific** re-installation of
218
221
TinyTeX for R. ** NOTE** however that this will uninstall the system-level
219
222
TinyTeX pre-installed in ` rocker/verse ` .
220
223
221
224
First, make sure ` /home/rstudio/bin ` is part of the ` PATH ` environment variable.
222
225
Check this by running
223
226
``` {bash check-path}
224
- docker exec --user rstudio rstudio_3.6.1 R --slave -e 'Sys.getenv("PATH")'
227
+ docker exec --user rstudio rstudio_4.3.2 R --slave -e 'Sys.getenv("PATH")'
225
228
```
226
229
If you don't see ` /home/rstudio/bin ` , you can make sure it is part of the ` PATH ` for R via
227
230
``` {bash set-path}
228
- docker exec --user rstudio rstudio_3.6.1 sh -c 'echo "PATH=$HOME/bin:\${PATH}" >> $HOME/.Renviron'
231
+ docker exec --user rstudio rstudio_4.3.2 sh -c 'echo "PATH=$HOME/bin:\${PATH}" >> $HOME/.Renviron'
229
232
# check again
230
- docker exec --user rstudio rstudio_3.6.1 R --slave -e 'Sys.getenv("PATH")'
233
+ docker exec --user rstudio rstudio_4.3.2 R --slave -e 'Sys.getenv("PATH")'
231
234
```
232
235
233
236
Then, from the running RStudio, run
@@ -239,7 +242,7 @@ tinytex::reinstall_tinytex()
239
242
### Cleanup
240
243
241
244
``` {bash cleanup}
242
- docker rm $(docker stop rstudio_3.6.1 )
245
+ docker rm $(docker stop rstudio_4.3.2 )
243
246
```
244
247
245
248
0 commit comments