For technically inclined users interested in an easy set up and full reproducibility, it may be interesting to set up R, RStudio, pandoc, TinyTex and the required LaTeX packages via the following Dockerfile:
# Select base image
ARG R_RELEASE="4.1.2"
ARG PAPAJA_BASE="papaja"
FROM rocker/rstudio:${R_RELEASE} AS papaja
# System libraries
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
libgsl0-dev \
libnlopt-dev \
libxt6 \
ssh
# TeX Live
ARG TEXLIVE_VERSION=2021
RUN if $TEXLIVE_VERSION == date +"%Y"; then \
CTAN_REPO=http://mirror.ctan.org/systems/texlive/tlnet; \
else \
CTAN_REPO=ftp://tug.org/historic/systems/texlive/$TEXLIVE_VERSION/tlnet-final; \
fi
ENV CTAN_REPO=$CTAN_REPO
RUN /rocker_scripts/install_texlive.sh
ENV PATH=$PATH:/usr/local/texlive/bin/x86_64-linux
RUN tlmgr install \
apa6 apa7 booktabs caption csquotes \
endfloat environ etoolbox fancyhdr \
fancyvrb framed lineno microtype mptopdf \
ms parskip pgf sttools threeparttable \
threeparttablex trimspaces txfonts upquote \
url was xcolor \
geometry amsmath kvoptions kvsetkeys kvdefinekeys ltxcmds zapfding \
auxhook infwarerr multirow babel-english stringenc uniquecounter \
epstopdf-pkg grfext bigintcalc bitset etexcmds gettitlestring \
hycolor hyperref intcalc letltxmacro pdfescape refcount rerunfilecheck \
latexdiff ulem oberdiek
# Setup R packages
ARG NCPUS=1
RUN install2.r --error \
--skipinstalled \
--ncpus $NCPUS \
tinytex \
remotes \
markdown \
mime
## Latest papaja development version
ARG PAPAJA_VERSION="@devel"
RUN Rscript -e "remotes::install_github('crsh/papaja$PAPAJA_VERSION', dependencies = c('Depends', 'Imports'), Ncpus = $NCPUS, upgrade = FALSE, build = TRUE)"
FROM ${PAPAJA_BASE} as project
# Install packages specified in DESCRIPTION
COPY DESCRIPTION* /home/rstudio/
WORKDIR /home/rstudio/
RUN if test -f DESCRIPTION ; then \
install2.r --error \
--skipinstalled \
$(Rscript -e "pkg <- remotes:::load_pkg_description('.'); repos <- c('https://cloud.r-project.org', remotes:::parse_additional_repositories(pkg)); deps <- remotes:::local_package_deps(pkgdir = '.', dependencies = NA); write(paste0(deps[!deps %in% c('papaja')], collapse = ' '), stdout())"); \
fi
RUN rm -f DESCRIPTION
RUN rm -rf /tmp/downloaded_packages
The project can then be easily run via the following bash script:
#!/bin/sh
# PAPAJA_BASE is the name used for the base image that can be reused across
# projects to save disk space and get up and running more quickly
#
# PROJECT_NAME is the name used for the image of the current project (including
# project-specific R packages etc.)
#
# Names must be lowercase.
PAPAJA_BASE="papaja"
PROJECT_NAME="papajaworkshop"
# Look up available R_RELEASE's at
# https://github.com/rocker-org/rocker-versioned2/tree/master/stacks
#
# PAPAJA_VERSION's are appended to the repostiory URL;
# see ?remotes::install_github
#
# For valid RSTUDIO_VERSION's refer to
# https://www.rstudio.com/products/rstudio/release-notes/
#
# Any year starting from 2000 is a valid TEXLIVE_VERSION
R_RELEASE="4.1.2"
PAPAJA_VERSION="@devel" # Eventually we should only accept releases here
RSTUDIO_VERSION="2021.09.0+351"
TEXLIVE_VERSION="2021"
# NCPUS controls the number of cores to use to install R packages in parallel
NCPUS=1
# ------------------------------------------------------------------------------
TAG="$R_RELEASE-$(echo $PAPAJA_VERSION | grep -o "\w*$")-$(echo $RSTUDIO_VERSION | grep -o "^[0-9]*\.[0-9][0-9]")-$TEXLIVE_VERSION"
PAPAJA_BASE="papaja:$TAG"
PROJECT_NAME="$PROJECT_NAME:$TAG"
docker build \
--build-arg R_RELEASE=$R_RELEASE \
--build-arg RSTUDIO_VERSION=$RSTUDIO_VERSION \
--build-arg TEXLIVE_VERSION=$TEXLIVE_VERSION \
--build-arg PAPAJA_VERSION=$PAPAJA_VERSION \
--build-arg NCPUS=$NCPUS \
--target papaja \
-t $PAPAJA_BASE .
docker build \
--build-arg PAPAJA_BASE=$PAPAJA_BASE \
--build-arg PROJECT_NAME=$PROJECT_NAME \
--build-arg NCPUS=$NCPUS \
--target project \
-t $PROJECT_NAME .
# Add as needed to work with git inside the container
#
# Share global .gitconfig with container
# -v ~/.gitconfig:/home/rstudio/.gitconfig:ro \
#
# Share SSH credentials with container
# -v ~/.ssh:/home/rstudio/.ssh:ro \
docker run -d \
-p 8787:8787 \
-e DISABLE_AUTH=TRUE \
-e ROOT=TRUE \
-v "/$PWD":/home/rstudio \
--name $(echo $PROJECT_NAME | grep -o "^[a-zA-Z0-9]*") \
--rm \
$PROJECT_NAME
sleep 1
git web--browse http://localhost:8787
For technically inclined users interested in an easy set up and full reproducibility, it may be interesting to set up R, RStudio, pandoc, TinyTex and the required LaTeX packages via the following Dockerfile:
The project can then be easily run via the following bash script: