Skip to content

Instantly share code, notes, and snippets.

@BerriJ
Created August 18, 2021 10:30
Show Gist options
  • Save BerriJ/3a793e167886d915aae4b93a1ba2eb54 to your computer and use it in GitHub Desktop.
Save BerriJ/3a793e167886d915aae4b93a1ba2eb54 to your computer and use it in GitHub Desktop.
Dockerfile vscDebugger Problem
FROM ubuntu:focal
SHELL ["/bin/bash", "-c"]
ENV R_VERSION=4.1.1 \
# See https://packagemanager.rstudio.com/client/#/repos/1/overview
R_REPOS=https://packagemanager.rstudio.com/all/__linux__/focal/4526215 \
DISPLAY=:0 \
TZ=Europe/Berlin
ARG DEBIAN_FRONTEND=noninteractive
# Ubuntu Setup
RUN apt-get update &&\
apt-get -y --no-install-recommends install \
software-properties-common \
git \
build-essential \
tar \
curl \
dirmngr \
gnupg-agent \
fontconfig \
pandoc \
perl \
python3-pip \
wget \
libcurl4-openssl-dev \
openssl \
libssl-dev \
libmagick++-dev \
libpoppler-cpp-dev \
netbase \
libxml2-dev \
gdb \
libgsl-dev \
libudunits2-dev \
libgdal-dev \
libharfbuzz-dev \
libfribidi-dev \
vim \
cargo \
locales &&\
locale-gen en_US.UTF-8
# Install R
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys \
E298A3A825C0D65DFD57CBB651716619E084DAB9 \
&& add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/' \
&& apt-get -y install --no-install-recommends r-base=${R_VERSION}* r-base-core=${R_VERSION}* \
r-recommended=${R_VERSION}* r-base-dev=${R_VERSION}*
# This does not work:
RUN Rscript -e "install.packages('devtools', repos= '$R_REPOS')"
RUN Rscript -e "remotes::install_github('ManuelHentschel/vscDebugger@v0.4.7', repos= '$R_REPOS')"
# This works:
# RUN Rscript -e "remotes::install_github('ManuelHentschel/vscDebugger@v0.4.5', repos= '$R_REPOS')"
# Set the default shell to zsh rather than bash
ENTRYPOINT [ "/bin/zsh" ]
@eitsupi
Copy link

eitsupi commented Aug 21, 2021

@BerriJ I'm curious, why do you install R on ubuntu:focal by yourself without using rocker/r-ver?
rocker/r-ver after R 4.0.0 is based on ubuntu:focal, and RSPM is set from the beginning, and there are many users in the derived image (rocker/rstudio, rocker/tidyverse, etc.).

@BerriJ
Copy link
Author

BerriJ commented Aug 21, 2021

Hey @eitsupi so there are a few reasons to do so.

The main reason is to know exactly how permissions are set and what is included in the container. The Docker file above only presents a small part of the entire devcontainer: https://github.com/BerriJ/devenv
You can see that I also include Python, Latex and C++ related stuff.
So one could ask: why not use a python/latex/c++ image as the base.
In the end I tried various things (also rocker) but ended up craving it from the ground up to set all permissions, users, settings etc. exactly how I want it (although I admit copying some parts from rocker 😇). Setting permissions was the hardest part because I did not want to just use the root user (because I do mount various folder into the container and then newly created files would be owned by root on the host system) but I also wanted to get install.packages (for R), pip (for python) and tlmgr (for Latex) working. The latter 2 are not possible using rocker images (without modifications), correct me if I'm wrong.
I also tag my images with dates so that I can easily jump back if necessary.
And last but also important: I tend to update my container only in times where I don't have very important projects / deadlines. So I'm in charge of when anything changes in the container (potentially breaking stuff).
Feel free to check it out. 😃

@eitsupi
Copy link

eitsupi commented Aug 22, 2021

@BerriJ Thank you very much for your detailed explanation.
I also think that complex images with several different languages installed generally need to be built by yourself.

However, it seems that rocker/r-ver also includes scripts to install pip and tlmgr packages. (I don't know if it fits your use case)

https://github.com/rocker-org/rocker-versioned2/blob/30fca60a9241fc1e3abc8ec9f16d4639f4343f29/scripts/install_python.sh
https://github.com/rocker-org/rocker-versioned2/blob/326dfed8cc12218e1bc3c28926eb811127e50625/scripts/install_texlive.sh

For example, rocker/verse, which already run the install_texlive.sh, seems to be quite widely used when R is used with latex. (I don't use latex myself and I'm not familiar with it, so I apologize if I'm wrong.)

And last but also important: I tend to update my container only in times where I don't have very important projects / deadlines. So I'm in charge of when anything changes in the container (potentially breaking stuff).

FYI, as you may know, in general, if you specify the Digest of an image, the pulled image will always be the same, and on GitHub, you can set dependabot to detect Digest changes and automatically create a PR when a new image is pushed.

FROM rocker/r-ver:4.1.1@sha256:f060daf95622ba9b8271dc6067036f98ed92bcd876b56827e4c3260ca162585d

https://dependabot.com/blog/dependabot-now-supports-docker/

@BerriJ
Copy link
Author

BerriJ commented Aug 22, 2021

Thank you! In particular for the dependabot hint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment