Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

[R] Support for R package pre-installed images and arm64 images #1327

Merged
merged 3 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions containers/r/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# R version: 4, 4.1, 4.0
ARG VARIANT="4"
FROM rocker/r-ver:${VARIANT}
# [Choice] R version: 4, 4.1, 4.0
ARG VARIANT=4
# [Choice] Base image. Minimal (r-ver), tidyverse installed (tidyverse), or full image (binder): rocker/r-ver, rocker/tidyverse, rocker/binder
ARG BASE_IMAGE=rocker/r-ver
FROM ${BASE_IMAGE}:${VARIANT}

# Use the [Option] comment to specify true/false arguments that should appear in VS Code UX
#
# [Option] Install zsh
ARG INSTALL_ZSH="true"
# [Option] Upgrade OS packages to their latest versions
ARG UPGRADE_PACKAGES="false"

# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
ARG USERNAME=vscode
ARG USERNAME=rstudio
ARG USER_UID=1000
ARG USER_GID=$USER_UID
USER root
COPY library-scripts/*.sh /tmp/library-scripts/
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
Expand All @@ -24,6 +25,8 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
libssl-dev \
libxml2-dev \
libxt-dev \
libfontconfig1-dev \
libcairo2-dev \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts \
&& python3 -m pip --no-cache-dir install radian \
&& install2.r --error --skipinstalled --ncpus -1 \
Expand All @@ -41,18 +44,25 @@ RUN export TAG=$(git ls-remote --tags --refs --sort='version:refname' https://gi
# See more details: https://github.com/REditorSupport/vscode-R/wiki/R-Session-watcher
RUN echo 'source(file.path(Sys.getenv("HOME"), ".vscode-R", "init.R"))' >> ${R_HOME}/etc/Rprofile.site

# [Option] Enable vscode-jupyter support
ARG ENABLE_JUPYTER="false"
RUN if [ "${ENABLE_JUPYTER}" = "true" ]; then \
if [ -z "$(dpkg --get-selections | grep libzmq3-dev)" ]; then \
apt-get update \
&& export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends libzmq3-dev \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*; \
fi \
&& install2.r --error --skipinstalled --ncpus -1 IRkernel \
&& rm -rf /tmp/downloaded_packages \
&& python3 -m pip --no-cache-dir install jupyter \
&& R --vanilla -s -e 'IRkernel::installspec(user = FALSE)'; \
fi

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update \
# && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# [Optional] Uncomment this section to install additional R packages.
# RUN install2.r --error --skipinstalled --ncpus -1 <your-package-list-here>

# [Optional] Uncomment this section to install vscode-jupyter dependencies.
# RUN apt-get update \
# && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends libzmq3-dev \
# && install2.r --error --skipinstalled --ncpus -1 IRkernel \
# && python3 -m pip --no-cache-dir install jupyter \
# && R --vanilla -s -e 'IRkernel::installspec(user = FALSE)'
14 changes: 11 additions & 3 deletions containers/r/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@
"name": "R (Community)",
"build": {
"dockerfile": "Dockerfile",
// Update VARIANT to pick a specific R version: 4, 4.1, 4.0
"args": { "VARIANT": "4" }
"args": {
// Update VARIANT to pick a R version: 4, 4.1, 4.0
"VARIANT": "4",
// Start with a minimal image (rocker/r-ver) or a expanded image.
// See more details about rocker/r-ver's derived images: https://github.com/rocker-org/rocker-versioned2
"BASE_IMAGE": "rocker/r-ver",
// Options
"ENABLE_JUPYTER": "false"
}
},

// Set *default* container specific settings.json values on container create.
Expand All @@ -17,6 +24,7 @@
},

// Add the IDs of extensions you want installed when the container is created.
// For example, if you want to use vscode-jupyter, add "ms-toolsai.jupyter".
"extensions": [
"ikuyadeu.r",
"rdebugger.r-debugger"
Expand All @@ -29,5 +37,5 @@
// "postCreateCommand": "R --version",

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
"remoteUser": "rstudio"
}