Skip to content
Snippets Groups Projects
Commit bfbba9d3 authored by SamCH93's avatar SamCH93
Browse files

Docker reproducibility

parent 5b1b2032
No related branches found
No related tags found
No related merge requests found
...@@ -46,3 +46,4 @@ rsAbsence.pdf ...@@ -46,3 +46,4 @@ rsAbsence.pdf
# some folders # some folders
misc/ misc/
submission/
## set R version (https://hub.docker.com/r/rocker/verse/tags) ## set R version (https://hub.docker.com/r/rocker/verse/tags)
FROM rocker/verse:4.2.3 FROM rocker/verse:4.3
## name of the manuscript (as in Makefile and paper/Makefile) ## name of the manuscript (as in Makefile and paper/Makefile)
ENV FILE=rsabsence ENV FILE=rsabsence
......
...@@ -13,19 +13,10 @@ dbuild: Dockerfile ...@@ -13,19 +13,10 @@ dbuild: Dockerfile
docker build \ docker build \
-t $(FILE) . -t $(FILE) .
## run docker image that produces pdf from within docker ## run docker image that produces *tex* from within docker
## and compiles to *pdf* outside docker
docker: dbuild docker: dbuild
docker run \ docker run \
--rm \
--env pdfdocker="true" \
--env FILE=$(FILE) \
--volume $(CURDIR):/output \
$(FILE)
mv $(FILE).pdf ./
## run docker image that produces tex from within docker
docker2: dbuild
docker run \
--rm \ --rm \
--env FILE=$(FILE) \ --env FILE=$(FILE) \
-v $(CURDIR):/output \ -v $(CURDIR):/output \
...@@ -37,3 +28,13 @@ docker2: dbuild ...@@ -37,3 +28,13 @@ docker2: dbuild
rmdir figure/ rmdir figure/
cd paper && make pdf2 clean cd paper && make pdf2 clean
mv paper/$(FILE).pdf ./ mv paper/$(FILE).pdf ./
## run docker image that produces *pdf* from within docker
docker2: dbuild
docker run \
--rm \
--env pdfdocker="true" \
--env FILE=$(FILE) \
--volume $(CURDIR):/output \
$(FILE)
mv $(FILE).pdf ./
...@@ -11,35 +11,41 @@ Our results can be reproduced in two ways ...@@ -11,35 +11,41 @@ Our results can be reproduced in two ways
### 1. Reproducing the results locally ### 1. Reproducing the results locally
Make sure that LaTeX (e.g., texlive-full on Ubuntu), R, and the R packages
indicated in the `./CRANpackages.txt` file are installed Make sure that R, and the R packages indicated in the `./CRANpackages.txt` file
are installed
```sh ```sh
## install packages from CRAN by running from a shell ## install packages from CRAN by running from a shell
R -e 'install.packages(read.delim("CRANpackages.txt", header = FALSE)[,1])' R -e 'install.packages(read.delim("CRANpackages.txt", header = FALSE)[,1])'
``` ```
Then run To only rerun the R code without recompiling the manuscript use the file
`./paper/rsabsence.R`. To recompile the manuscript, make also sure that Make,
LaTeX and all necessary LaTeX packages (e.g., the texlive-full distribution on
Ubuntu) are installed. Then run
``` ```
make local make local
``` ```
this should produce `./rsabsence.pdf` this should produce `./rsabsence.pdf`.
Although the analyses depend on only few dependencies, this approach may lead to Although the analyses depend on only few dependencies, this approach may lead to
different results (or not even compile successfully) in the future if R or the different results (or not even compile successfully) in the future if R or the
packages change. The R and R package versions which were used when the thesis packages change. The R and R package versions which were used when the paper was
was successfully compiled the last time are visible in the following output successfully compiled before submission are visible in the following output
```r ```r
sessionInfo() sessionInfo()
#> R version 4.2.3 (2023-03-15) #> R version 4.3.0 (2023-04-21)
#> Platform: x86_64-pc-linux-gnu (64-bit) #> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Ubuntu 20.04.6 LTS #> Running under: Ubuntu 20.04.6 LTS
#>
#> Matrix products: default #> Matrix products: default
#> BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0 #> BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.9.0
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0 #> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.9.0
#> #>
#> locale: #> locale:
...@@ -50,40 +56,42 @@ sessionInfo() ...@@ -50,40 +56,42 @@ sessionInfo()
#> [9] LC_ADDRESS=C LC_TELEPHONE=C #> [9] LC_ADDRESS=C LC_TELEPHONE=C
#> [11] LC_MEASUREMENT=de_CH.UTF-8 LC_IDENTIFICATION=C #> [11] LC_MEASUREMENT=de_CH.UTF-8 LC_IDENTIFICATION=C
#> #>
#> time zone: Europe/Zurich
#> tzcode source: system (glibc)
#>
#> attached base packages: #> attached base packages:
#> [1] stats graphics grDevices utils datasets methods base #> [1] stats graphics grDevices utils datasets methods base
#> #>
#> other attached packages: #> other attached packages:
#> [1] reporttools_1.1.3 xtable_1.8-4 dplyr_1.1.1 gridExtra_2.3 #> [1] reporttools_1.1.3 xtable_1.8-4 dplyr_1.1.2 gridExtra_2.3
#> [5] ggplot2_3.4.2 knitr_1.42 #> [5] ggplot2_3.4.2 knitr_1.42
#> #>
#> loaded via a namespace (and not attached): #> loaded via a namespace (and not attached):
#> [1] fansi_1.0.4 withr_2.5.0 utf8_1.2.3 grid_4.2.3 #> [1] vctrs_0.6.2 cli_3.6.1 rlang_1.1.0 xfun_0.39
#> [5] R6_2.5.1 lifecycle_1.0.3 gtable_0.3.3 magrittr_2.0.3 #> [5] generics_0.1.3 labeling_0.4.2 glue_1.6.2 colorspace_2.1-0
#> [9] scales_1.2.1 pillar_1.9.0 rlang_1.1.0 cli_3.6.1 #> [9] scales_1.2.1 fansi_1.0.4 grid_4.3.0 munsell_0.5.0
#> [13] generics_0.1.3 vctrs_0.6.1 tools_4.2.3 glue_1.6.2 #> [13] tibble_3.2.1 lifecycle_1.0.3 compiler_4.3.0 pkgconfig_2.0.3
#> [17] munsell_0.5.0 xfun_0.38 compiler_4.2.3 pkgconfig_2.0.3 #> [17] farver_2.1.1 viridisLite_0.4.1 R6_2.5.1 tidyselect_1.2.0
#> [21] colorspace_2.1-0 tidyselect_1.2.0 tibble_3.2.1 #> [21] utf8_1.2.3 pillar_1.9.0 magrittr_2.0.3 tools_4.3.0
#> [25] withr_2.5.0 gtable_0.3.3
cat(paste(Sys.time(), Sys.timezone(), "\n")) cat(paste(Sys.time(), Sys.timezone(), "\n"))
#> 2023-04-06 13:56:17 Europe/Zurich #> 2023-05-08 09:19:12.440643 Europe/Zurich
``` ```
### 2. Reproducing the results within a Docker container ### 2. Reproducing the results within a Docker container
Make sure that Docker with root rights is installed. Then run Make sure that Make, LaTeX with all necessary packages (e.g., the texlive-full
distribution on Ubuntu), and Docker with root rights are installed. Then run
``` ```
make docker make docker
``` ```
This may take some time as TinyTeX needs to install several LaTeX packages (run The Docker approach reruns the analyses in a Docker container which encapsulates
`make docker2` to compile only R code within the container but run LaTeX the computational environment (R and R package versions) that was used in the
locally). The Docker approach reruns the analyses in a Docker container which original analysis. The only way this approach could become non-reproducible is
encapsulates the computational environment (R and R package versions) that was when the [rocker/verse](https://hub.docker.com/r/rocker/verse/tags) base image
used in the original analysis. The only way this approach could become becomes unavailable and/or the Posit Public Package Manager (RStudio Package
non-reproducible is when the Manager, RSPM) snapshot of CRAN becomes unavailable.
[rocker/verse](https://hub.docker.com/r/rocker/verse/tags) base image becomes
unavailable and/or the Posit Public Package Manager (RStudio Package Manager,
RSPM) snapshot of CRAN becomes unavailable.
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment