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

Add R - Jupyter - R Markdown - Data Science - Machine Learning DevConatiner #1314

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# R version: 4, 4.1, 4.0
ARG VARIANT="4"
FROM rocker/r-ver:${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 USER_UID=1000
ARG USER_GID=$USER_UID
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" \
&& usermod -a -G staff ${USERNAME} \
&& apt-get -y install \
python3-pip \
libgit2-dev \
libxml2-dev \
pandoc \
libxt-dev \
# Set up R Kernel for Jupyter Notebooks.
# See more details: https://irkernel.github.io/installation/#source-panel
libzmq3-dev \
libcurl4-openssl-dev \
libssl-dev \
jupyter-core \
jupyter-client \
&& 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 \
devtools \
languageserver \
httpgd \
tidyverse \
tidymodels \
statip \
patchwork \
paletteer \
glmnet \
randomForest \
xgboost \
here \
doParallel \
janitor \
vip \
ranger \
palmerpenguins \
skimr \
nnet \
kernlab \
plotly \
factoextra \
cluster \
ottr \
&& rm -rf /tmp/downloaded_packages

# Install summarytools and load some R package off the bat
RUN R -e "devtools::install_github('https://github.com/dcomtois/summarytools/tree/0-8-9')"
RUN R -e "library(ottr)"
RUN R -e "library(here)"
RUN R -e "library(languageserver)"
# RUN installGithub.r ucbds-infra/ottr@stable

# Set up R and Python Kernels for Jupyter Notebooks.
# See more details: https://irkernel.github.io/installation/#source-panel
RUN R -e "install.packages(c('repr', 'IRdisplay', 'IRkernel'), type = 'source')"
RUN R -e "IRkernel::installspec()"
RUN python3 -m pip install -U ipykernel

# VSCode R Debugger dependency. Install the latest release version from GitHub without using GitHub API.
# See https://github.com/microsoft/vscode-dev-containers/issues/1032
RUN export TAG=$(git ls-remote --tags --refs --sort='version:refname' https://github.com/ManuelHentschel/vscDebugger v\* | tail -n 1 | cut --delimiter='/' --fields=3) \
&& Rscript -e "remotes::install_git('https://github.com/ManuelHentschel/vscDebugger.git', ref = '"${TAG}"', dependencies = FALSE)"

# R Session watcher settings.
# 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

# [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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{
"name": "R Data Science Environment",
"build": {
"dockerfile": "Dockerfile",
// Update VARIANT to pick a specific R version: 4, 4.1, 4.0
"args": { "VARIANT": "4" }
},

// Set *default* container specific settings.json values on container create.
"settings": {
"r.rpath.linux": "/usr/local/lib/R/bin/R",
"r.rterm.linux": "/usr/local/bin/radian",
"r.bracketedPaste": true,
"r.plot.useHttpgd": true,
"r.lsp.enabled": true,
"[r]": {
"editor.wordSeparators": "`~!@#%$^&*()-=+[{]}\\|;:'\",<>/?"
}
},

// Add the IDs of extensions you want installed when the container is created.
"extensions": [
// Add Jupyter, R and Python vscode extensions
"ikuyadeu.r",
"rdebugger.r-debugger",
"ms-toolsai.jupyter",
"ms-python.python",

// Other extensions that make life a little bit easier right off the bat
"ionutvmi.path-autocomplete",
"usernamehw.errorlens",
"mhutchie.git-graph",
"tomoki1207.pdf",
"DavidAnson.vscode-markdownlint",
"Rubymaniac.vscode-paste-and-indent",
"GrapeCity.gc-excelviewer",
"IBM.output-colorizer",
"Mohamed-El-Fodil-Ihaddaden.shinysnip",
"hediet.vscode-drawio",
"MS-vsliveshare.vsliveshare-pack",
"eamodio.gitlens",
"GitHub.vscode-pull-request-github"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "R --version",

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
// Jupyter seems to detect the R kernel out of the box when user is root
//"remoteUser": "vscode"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Warning: Folder contents may be replaced

The contents of this folder will be automatically replaced with a file of the same name in the [vscode-dev-containers](https://github.com/microsoft/vscode-dev-containers) repository's [script-library folder](https://github.com/microsoft/vscode-dev-containers/tree/main/script-library) whenever the repository is packaged.

To retain your edits, move the file to a different location. You may also delete the files if they are not needed.
Loading