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

Commit 1971f2a

Browse files
authored
[R] Support for R package pre-installed images and arm64 images (#1327)
1 parent 9a65151 commit 1971f2a

File tree

2 files changed

+35
-17
lines changed

2 files changed

+35
-17
lines changed

containers/r/.devcontainer/Dockerfile

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
# R version: 4, 4.1, 4.0
2-
ARG VARIANT="4"
3-
FROM rocker/r-ver:${VARIANT}
1+
# [Choice] R version: 4, 4.1, 4.0
2+
ARG VARIANT=4
3+
# [Choice] Base image. Minimal (r-ver), tidyverse installed (tidyverse), or full image (binder): rocker/r-ver, rocker/tidyverse, rocker/binder
4+
ARG BASE_IMAGE=rocker/r-ver
5+
FROM ${BASE_IMAGE}:${VARIANT}
46

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

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

47+
# [Option] Enable vscode-jupyter support
48+
ARG ENABLE_JUPYTER="false"
49+
RUN if [ "${ENABLE_JUPYTER}" = "true" ]; then \
50+
if [ -z "$(dpkg --get-selections | grep libzmq3-dev)" ]; then \
51+
apt-get update \
52+
&& export DEBIAN_FRONTEND=noninteractive \
53+
&& apt-get -y install --no-install-recommends libzmq3-dev \
54+
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*; \
55+
fi \
56+
&& install2.r --error --skipinstalled --ncpus -1 IRkernel \
57+
&& rm -rf /tmp/downloaded_packages \
58+
&& python3 -m pip --no-cache-dir install jupyter \
59+
&& R --vanilla -s -e 'IRkernel::installspec(user = FALSE)'; \
60+
fi
61+
4462
# [Optional] Uncomment this section to install additional OS packages.
4563
# RUN apt-get update \
4664
# && export DEBIAN_FRONTEND=noninteractive \
4765
# && apt-get -y install --no-install-recommends <your-package-list-here>
4866

4967
# [Optional] Uncomment this section to install additional R packages.
5068
# RUN install2.r --error --skipinstalled --ncpus -1 <your-package-list-here>
51-
52-
# [Optional] Uncomment this section to install vscode-jupyter dependencies.
53-
# RUN apt-get update \
54-
# && export DEBIAN_FRONTEND=noninteractive \
55-
# && apt-get -y install --no-install-recommends libzmq3-dev \
56-
# && install2.r --error --skipinstalled --ncpus -1 IRkernel \
57-
# && python3 -m pip --no-cache-dir install jupyter \
58-
# && R --vanilla -s -e 'IRkernel::installspec(user = FALSE)'

containers/r/.devcontainer/devcontainer.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,15 @@
22
"name": "R (Community)",
33
"build": {
44
"dockerfile": "Dockerfile",
5-
// Update VARIANT to pick a specific R version: 4, 4.1, 4.0
6-
"args": { "VARIANT": "4" }
5+
"args": {
6+
// Update VARIANT to pick a R version: 4, 4.1, 4.0
7+
"VARIANT": "4",
8+
// Start with a minimal image (rocker/r-ver) or a expanded image.
9+
// See more details about rocker/r-ver's derived images: https://github.com/rocker-org/rocker-versioned2
10+
"BASE_IMAGE": "rocker/r-ver",
11+
// Options
12+
"ENABLE_JUPYTER": "false"
13+
}
714
},
815

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

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

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

0 commit comments

Comments
 (0)