├── .devcontainer.json ├── .editorconfig ├── .github ├── dependabot.yml └── workflows │ ├── actions │ └── smoke-test │ │ ├── action.yaml │ │ ├── build.sh │ │ └── test.sh │ ├── lint.yaml │ ├── release.yaml │ └── test.yaml ├── .gitignore ├── .yaml-lint.yml ├── LICENSE ├── README.md ├── src ├── r-ver │ ├── .devcontainer │ │ └── devcontainer.json │ ├── .github │ │ └── dependabot.yml │ ├── NOTES.md │ ├── README.md │ └── devcontainer-template.json └── r2u │ ├── .devcontainer │ └── devcontainer.json │ ├── .github │ └── dependabot.yml │ ├── NOTES.md │ ├── README.md │ └── devcontainer-template.json └── test ├── r-ver └── test.sh ├── r2u └── test.sh └── test-utils └── test-utils.sh /.devcontainer.json: -------------------------------------------------------------------------------- 1 | { 2 | "image": "mcr.microsoft.com/vscode/devcontainers/javascript-node:0-18", 3 | "customizations": { 4 | "vscode": { 5 | "extensions": [ 6 | "mads-hartmann.bash-ide-vscode", 7 | "EditorConfig.EditorConfig", 8 | "foxundermoon.shell-format", 9 | "timonwong.shellcheck", 10 | "redhat.vscode-yaml" 11 | ], 12 | "settings": { 13 | "terminal.integrated.defaultProfile.linux": "zsh" 14 | } 15 | } 16 | }, 17 | "features": { 18 | "ghcr.io/devcontainers/features/docker-in-docker:2": { 19 | "version": "latest" 20 | } 21 | }, 22 | "postCreateCommand": "npm install -g @devcontainers/cli" 23 | } 24 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | [*] 2 | insert_final_newline = true 3 | end_of_line = lf 4 | 5 | [*.json] 6 | indent_style = tab 7 | 8 | [*.sh] 9 | indent_style = space 10 | indent_size = 4 11 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | -------------------------------------------------------------------------------- /.github/workflows/actions/smoke-test/action.yaml: -------------------------------------------------------------------------------- 1 | name: "Smoke test" 2 | 3 | inputs: 4 | template: 5 | description: "Template to test" 6 | required: true 7 | 8 | runs: 9 | using: composite 10 | steps: 11 | - name: Checkout main 12 | id: checkout_release 13 | uses: actions/checkout@v3 14 | 15 | - name: Build template 16 | id: build_template 17 | shell: bash 18 | run: ${{ github.action_path }}/build.sh ${{ inputs.template }} 19 | 20 | - name: Test template 21 | id: test_template 22 | shell: bash 23 | run: ${{ github.action_path }}/test.sh ${{ inputs.template }} 24 | -------------------------------------------------------------------------------- /.github/workflows/actions/smoke-test/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | TEMPLATE_ID="$1" 3 | 4 | set -e 5 | 6 | shopt -s dotglob 7 | 8 | SRC_DIR="/tmp/${TEMPLATE_ID}" 9 | cp -R "src/${TEMPLATE_ID}" "${SRC_DIR}" 10 | 11 | pushd "${SRC_DIR}" 12 | 13 | # Configure templates only if `devcontainer-template.json` contains the `options` property. 14 | # shellcheck disable=SC2048 disable=SC2207 15 | OPTION_PROPERTY=($(jq -r '.options' devcontainer-template.json)) 16 | 17 | # shellcheck disable=SC2048 disable=SC2128 18 | if [ "${OPTION_PROPERTY}" != "" ] && [ "${OPTION_PROPERTY}" != "null" ]; then 19 | # shellcheck disable=SC2048 disable=SC2207 20 | OPTIONS=($(jq -r '.options | keys[]' devcontainer-template.json)) 21 | 22 | if [ "${OPTIONS[0]}" != "" ] && [ "${OPTIONS[0]}" != "null" ]; then 23 | echo "(!) Configuring template options for '${TEMPLATE_ID}'" 24 | for OPTION in "${OPTIONS[@]}"; do 25 | OPTION_KEY="\${templateOption:$OPTION}" 26 | OPTION_VALUE=$(jq -r ".options | .${OPTION} | .default" devcontainer-template.json) 27 | 28 | if [ "${OPTION_VALUE}" = "" ] || [ "${OPTION_VALUE}" = "null" ]; then 29 | echo "Template '${TEMPLATE_ID}' is missing a default value for option '${OPTION}'" 30 | exit 1 31 | fi 32 | 33 | echo "(!) Replacing '${OPTION_KEY}' with '${OPTION_VALUE}'" 34 | OPTION_VALUE_ESCAPED=$(sed -e 's/[]\/$*.^[]/\\&/g' <<<"${OPTION_VALUE}") 35 | find ./ -type f -print0 | xargs -0 sed -i "s/${OPTION_KEY}/${OPTION_VALUE_ESCAPED}/g" 36 | done 37 | fi 38 | fi 39 | 40 | popd 41 | 42 | TEST_DIR="test/${TEMPLATE_ID}" 43 | if [ -d "${TEST_DIR}" ]; then 44 | echo "(*) Copying test folder" 45 | DEST_DIR="${SRC_DIR}/test-project" 46 | mkdir -p "${DEST_DIR}" 47 | cp -Rp "${TEST_DIR}"/* "${DEST_DIR}" 48 | cp test/test-utils/test-utils.sh "${DEST_DIR}" 49 | fi 50 | 51 | export DOCKER_BUILDKIT=1 52 | echo "(*) Installing @devcontainer/cli" 53 | npm install -g @devcontainers/cli 54 | 55 | echo "Building Dev Container" 56 | ID_LABEL="test-container=${TEMPLATE_ID}" 57 | devcontainer up --id-label "${ID_LABEL}" --workspace-folder "${SRC_DIR}" 58 | -------------------------------------------------------------------------------- /.github/workflows/actions/smoke-test/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | TEMPLATE_ID="$1" 3 | set -e 4 | 5 | SRC_DIR="/tmp/${TEMPLATE_ID}" 6 | echo "Running Smoke Test" 7 | 8 | ID_LABEL="test-container=${TEMPLATE_ID}" 9 | # shellcheck disable=SC2048 disable=SC2016 10 | devcontainer exec --workspace-folder "${SRC_DIR}" --id-label "${ID_LABEL}" /bin/sh -c 'set -e && if [ -f "test-project/test.sh" ]; then cd test-project && if [ "$(id -u)" = "0" ]; then chmod +x test.sh; else sudo chmod +x test.sh; fi && ./test.sh; else ls -a; fi' 11 | 12 | # Clean up 13 | docker rm -f "$(docker container ls -f "label=${ID_LABEL}" -q)" 14 | rm -rf "${SRC_DIR}" 15 | -------------------------------------------------------------------------------- /.github/workflows/lint.yaml: -------------------------------------------------------------------------------- 1 | name: Lint Code Base 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - main 7 | 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.ref }} 10 | cancel-in-progress: true 11 | 12 | jobs: 13 | lint: 14 | name: Lint Code Base 15 | runs-on: ubuntu-latest 16 | steps: 17 | - name: Checkout Code 18 | uses: actions/checkout@v4 19 | with: 20 | fetch-depth: 0 21 | - name: Lint Code Base 22 | uses: github/super-linter@v5 23 | env: 24 | VALIDATE_ALL_CODEBASE: false 25 | DEFAULT_BRANCH: master 26 | LINTER_RULES_PATH: . 27 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 28 | -------------------------------------------------------------------------------- /.github/workflows/release.yaml: -------------------------------------------------------------------------------- 1 | name: Release dev container templates 2 | on: 3 | workflow_dispatch: 4 | 5 | concurrency: 6 | group: ${{ github.workflow }} 7 | cancel-in-progress: true 8 | 9 | jobs: 10 | deploy: 11 | if: ${{ github.ref == 'refs/heads/main' }} 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | 16 | - name: Publish 17 | uses: devcontainers/action@v1 18 | with: 19 | publish-templates: "true" 20 | base-path-to-templates: "./src" 21 | generate-docs: "true" 22 | env: 23 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 24 | 25 | - name: Create PR for Documentation 26 | id: push_image_info 27 | env: 28 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 29 | run: | 30 | set -e 31 | echo "Start." 32 | # Configure git and Push updates 33 | git config --global user.email github-actions@github.com 34 | git config --global user.name github-actions 35 | git config pull.rebase false 36 | branch=automated-documentation-update-$GITHUB_RUN_ID 37 | git checkout -b $branch 38 | message='Automated documentation update' 39 | # Add / update and commit 40 | git add */**/README.md 41 | git commit -m 'Automated documentation update [skip ci]' || export NO_UPDATES=true 42 | # Push 43 | if [ "$NO_UPDATES" != "true" ] ; then 44 | git push origin "$branch" 45 | gh pr create --title "$message" --body "$message" 46 | fi 47 | -------------------------------------------------------------------------------- /.github/workflows/test.yaml: -------------------------------------------------------------------------------- 1 | name: CI - Test Templates 2 | on: 3 | pull_request: 4 | branches: 5 | - main 6 | paths: 7 | - src/** 8 | - test/** 9 | - "!**.md" 10 | 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.ref }} 13 | cancel-in-progress: true 14 | 15 | jobs: 16 | detect-changes: 17 | runs-on: ubuntu-latest 18 | outputs: 19 | templates: ${{ steps.filter.outputs.changes }} 20 | steps: 21 | - uses: dorny/paths-filter@v3 22 | id: filter 23 | with: 24 | filters: | 25 | r-ver: ./**/r-ver/** 26 | r2u: ./**/r2u/** 27 | 28 | test-detects: 29 | if: ${{ github.event_name == 'pull_request' }} 30 | needs: 31 | - detect-changes 32 | runs-on: ubuntu-latest 33 | continue-on-error: true 34 | strategy: 35 | matrix: 36 | templates: ${{ fromJSON(needs.detect-changes.outputs.templates) }} 37 | steps: 38 | - uses: actions/checkout@v4 39 | 40 | - name: Smoke test for '${{ matrix.templates }}' 41 | id: smoke_test 42 | uses: ./.github/workflows/actions/smoke-test 43 | with: 44 | template: "${{ matrix.templates }}" 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /output/ 2 | -------------------------------------------------------------------------------- /.yaml-lint.yml: -------------------------------------------------------------------------------- 1 | extends: default 2 | 3 | rules: 4 | line-length: 5 | max: 120 6 | level: warning 7 | document-start: disable 8 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 Rocker Project 4 | Copyright (c) 2022 Microsoft Corporation 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | SOFTWARE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Development Container Templates (for R) 2 | 3 | This repository contains a set of Dev Container Templates for R. 4 | 5 | This repository is based on 6 | [the `devcontainers/templates` repository](https://github.com/devcontainers/templates) and 7 | [the `devcontainers/template-starter` repository](https://github.com/devcontainers/template-starter). 8 | -------------------------------------------------------------------------------- /src/r-ver/.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the 2 | // README at: https://github.com/rocker-org/devcontainer-templates/tree/main/src/r-ver 3 | { 4 | "name": "R (rocker/r-ver base)", 5 | // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile 6 | "image": "ghcr.io/rocker-org/devcontainer/${templateOption:baseVariant}:${templateOption:imageVariant}", 7 | 8 | // Features to add to the dev container. More info: https://containers.dev/features. 9 | // "features": {}, 10 | 11 | // Use 'forwardPorts' to make a list of ports inside the container available locally. 12 | // "forwardPorts": [], 13 | 14 | // Use 'postCreateCommand' to run commands after the container is created. 15 | // "postCreateCommand": "R -q -e 'renv::install()'", 16 | 17 | // Configure tool-specific properties. 18 | // "customizations": {}, 19 | 20 | // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. 21 | // "remoteUser": "root" 22 | } 23 | -------------------------------------------------------------------------------- /src/r-ver/.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for more information: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | # https://containers.dev/guide/dependabot 6 | 7 | version: 2 8 | updates: 9 | - package-ecosystem: "devcontainers" 10 | directory: "/" 11 | schedule: 12 | interval: weekly 13 | -------------------------------------------------------------------------------- /src/r-ver/NOTES.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## About base images 4 | 5 | Please check [the reference page](https://rocker-project.org/images/devcontainer/images.html). 6 | 7 | ## Install R packages 8 | 9 | Several Dev Container Features provided by the Rocker Project 10 | allow R package installation to be defined on `devcontainer.json`. 11 | 12 | ### Use [`pak`](https://pak.r-lib.org/) 13 | 14 | If you want to install R packages via Dev Container Features, 15 | you can use [the `ghcr.io/rocker-org/devcontainer-features/r-packages` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/r-packages). 16 | 17 | The images used in this template support installation of system dependencies 18 | via the [`pak::pak()`](https://pak.r-lib.org/reference/pak.html) function, 19 | so the R packages can be installed with `devcontainer.json` like below. 20 | 21 | ```json 22 | { 23 | "image": "ghcr.io/rocker-org/devcontainer/r-ver:4", 24 | "features": { 25 | "ghcr.io/rocker-org/devcontainer-features/r-packages:1": { 26 | "packages": "cli,rlang", 27 | "installSystemRequirements": true 28 | } 29 | } 30 | } 31 | ``` 32 | 33 | ### Use [`renv`](https://rstudio.github.io/renv/) 34 | 35 | [The `ghcr.io/rocker-org/devcontainer-features/renv-cache` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/renv-cache) 36 | can be used to store caches of R packages in a Docker volume. 37 | 38 | For example, when used in the development of an R package, all dependent packages in the project `DESCRIPTION` file 39 | can be installed via the [`renv::install()`](https://rstudio.github.io/renv/reference/install.html) function 40 | by setting `postCreateCommand` as follows. 41 | 42 | ```json 43 | { 44 | "image": "ghcr.io/rocker-org/devcontainer/r-ver:4", 45 | "features": { 46 | "ghcr.io/rocker-org/devcontainer-features/renv-cache:latest": {} 47 | }, 48 | "postCreateCommand": "R -q -e 'renv::install()'" 49 | } 50 | ``` 51 | 52 | The package cache is shared by all containers on the same machine, so later builds can be faster. 53 | 54 | ## Use [RStudio Server](https://posit.co/products/open-source/rstudio-server/) 55 | 56 | [The `ghcr.io/rocker-org/devcontainer-features/rstudio-server` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/rstudio-server) 57 | can be used to install and configure RStudio Server. 58 | 59 | ```json 60 | { 61 | "image": "ghcr.io/rocker-org/devcontainer/r-ver:4", 62 | "features": { 63 | "ghcr.io/rocker-org/devcontainer-features/rstudio-server:latest": {} 64 | } 65 | } 66 | ``` 67 | 68 | ## Use [Jupyter](https://jupyter.org/) 69 | 70 | [The `ghcr.io/rocker-org/devcontainer-features/r-rig` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/r-rig) 71 | can be used to install `jupyterlab` and `IRkernel`. 72 | (Remember to set `"version": "none"` for not to install another R) 73 | 74 | ```json 75 | { 76 | "image": "ghcr.io/rocker-org/devcontainer/r-ver:4", 77 | "features": { 78 | "ghcr.io/rocker-org/devcontainer-features/r-rig:1": { 79 | "version": "none", 80 | "installJupyterlab": true 81 | } 82 | } 83 | } 84 | ``` 85 | 86 | ## Make R console history persistent 87 | 88 | Normally the R console history is lost when we recreate the container, 89 | but we can preserve the history with 90 | [The `ghcr.io/rocker-org/devcontainer-features/r-history` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/r-history). 91 | 92 | ```json 93 | { 94 | "image": "ghcr.io/rocker-org/devcontainer/r-ver:4", 95 | "features": { 96 | "ghcr.io/rocker-org/devcontainer-features/r-history:0": {} 97 | } 98 | } 99 | ``` 100 | -------------------------------------------------------------------------------- /src/r-ver/README.md: -------------------------------------------------------------------------------- 1 | 2 | # R (rocker/r-ver base) (r-ver) 3 | 4 | A container-based development environment for the R language. Includes many commonly used R packages. 5 | 6 | ## Options 7 | 8 | | Options Id | Description | Type | Default Value | 9 | |-----|-----|-----|-----| 10 | | imageVariant | R version: | string | 4 | 11 | | baseVariant | Base image. Minimal (r-ver), tidyverse installed (tidyverse), or full image (geospatial). Only r-ver supports the arm64 platform: | string | r-ver | 12 | 13 | 14 | 15 | ## About base images 16 | 17 | Please check [the reference page](https://rocker-project.org/images/devcontainer/images.html). 18 | 19 | ## Install R packages 20 | 21 | Several Dev Container Features provided by the Rocker Project 22 | allow R package installation to be defined on `devcontainer.json`. 23 | 24 | ### Use [`pak`](https://pak.r-lib.org/) 25 | 26 | If you want to install R packages via Dev Container Features, 27 | you can use [the `ghcr.io/rocker-org/devcontainer-features/r-packages` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/r-packages). 28 | 29 | The images used in this template support installation of system dependencies 30 | via the [`pak::pak()`](https://pak.r-lib.org/reference/pak.html) function, 31 | so the R packages can be installed with `devcontainer.json` like below. 32 | 33 | ```json 34 | { 35 | "image": "ghcr.io/rocker-org/devcontainer/r-ver:4", 36 | "features": { 37 | "ghcr.io/rocker-org/devcontainer-features/r-packages:1": { 38 | "packages": "cli,rlang", 39 | "installSystemRequirements": true 40 | } 41 | } 42 | } 43 | ``` 44 | 45 | ### Use [`renv`](https://rstudio.github.io/renv/) 46 | 47 | [The `ghcr.io/rocker-org/devcontainer-features/renv-cache` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/renv-cache) 48 | can be used to store caches of R packages in a Docker volume. 49 | 50 | For example, when used in the development of an R package, all dependent packages in the project `DESCRIPTION` file 51 | can be installed via the [`renv::install()`](https://rstudio.github.io/renv/reference/install.html) function 52 | by setting `postCreateCommand` as follows. 53 | 54 | ```json 55 | { 56 | "image": "ghcr.io/rocker-org/devcontainer/r-ver:4", 57 | "features": { 58 | "ghcr.io/rocker-org/devcontainer-features/renv-cache:latest": {} 59 | }, 60 | "postCreateCommand": "R -q -e 'renv::install()'" 61 | } 62 | ``` 63 | 64 | The package cache is shared by all containers on the same machine, so later builds can be faster. 65 | 66 | ## Use [RStudio Server](https://posit.co/products/open-source/rstudio-server/) 67 | 68 | [The `ghcr.io/rocker-org/devcontainer-features/rstudio-server` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/rstudio-server) 69 | can be used to install and configure RStudio Server. 70 | 71 | ```json 72 | { 73 | "image": "ghcr.io/rocker-org/devcontainer/r-ver:4", 74 | "features": { 75 | "ghcr.io/rocker-org/devcontainer-features/rstudio-server:latest": {} 76 | } 77 | } 78 | ``` 79 | 80 | ## Use [Jupyter](https://jupyter.org/) 81 | 82 | [The `ghcr.io/rocker-org/devcontainer-features/r-rig` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/r-rig) 83 | can be used to install `jupyterlab` and `IRkernel`. 84 | (Remember to set `"version": "none"` for not to install another R) 85 | 86 | ```json 87 | { 88 | "image": "ghcr.io/rocker-org/devcontainer/r-ver:4", 89 | "features": { 90 | "ghcr.io/rocker-org/devcontainer-features/r-rig:1": { 91 | "version": "none", 92 | "installJupyterlab": true 93 | } 94 | } 95 | } 96 | ``` 97 | 98 | ## Make R console history persistent 99 | 100 | Normally the R console history is lost when we recreate the container, 101 | but we can preserve the history with 102 | [The `ghcr.io/rocker-org/devcontainer-features/r-history` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/r-history). 103 | 104 | ```json 105 | { 106 | "image": "ghcr.io/rocker-org/devcontainer/r-ver:4", 107 | "features": { 108 | "ghcr.io/rocker-org/devcontainer-features/r-history:0": {} 109 | } 110 | } 111 | ``` 112 | 113 | 114 | --- 115 | 116 | _Note: This file was auto-generated from the [devcontainer-template.json](https://github.com/rocker-org/devcontainer-templates/blob/main/src/r-ver/devcontainer-template.json). Add additional notes to a `NOTES.md`._ 117 | -------------------------------------------------------------------------------- /src/r-ver/devcontainer-template.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "r-ver", 3 | "version": "1.1.2", 4 | "name": "R (rocker/r-ver base)", 5 | "description": "A container-based development environment for the R language. Includes many commonly used R packages.", 6 | "documentationURL": "https://github.com/rocker-org/devcontainer-templates/tree/main/src/r-ver", 7 | "publisher": "Rocker Project", 8 | "licenseURL": "https://github.com/rocker-org/devcontainer-templates/blob/main/LICENSE", 9 | "options": { 10 | "imageVariant": { 11 | "type": "string", 12 | "description": "R version:", 13 | "proposals": [ 14 | "4", 15 | "4.4", 16 | "4.3" 17 | ], 18 | "default": "4" 19 | }, 20 | "baseVariant": { 21 | "type": "string", 22 | "description": "Base image. Minimal (r-ver), tidyverse installed (tidyverse), or full image (geospatial). Only r-ver supports the arm64 platform:", 23 | "proposals": [ 24 | "r-ver", 25 | "tidyverse", 26 | "geospatial" 27 | ], 28 | "default": "r-ver" 29 | } 30 | }, 31 | "platforms": [ 32 | "R" 33 | ], 34 | "optionalPaths": [ 35 | ".github/*" 36 | ] 37 | } 38 | -------------------------------------------------------------------------------- /src/r2u/.devcontainer/devcontainer.json: -------------------------------------------------------------------------------- 1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the 2 | // README at: https://github.com/rocker-org/devcontainer-templates/tree/main/src/r2u 3 | { 4 | "name": "R (r2u and bspm configured)", 5 | // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile 6 | "image": "mcr.microsoft.com/devcontainers/base:${templateOption:imageVariant}", 7 | 8 | // Features to add to the dev container. More info: https://containers.dev/features. 9 | "features": { 10 | // A Feature to configure R on Ubuntu. More info: https://github.com/rocker-org/devcontainer-features/tree/main/src/r-apt. 11 | "ghcr.io/rocker-org/devcontainer-features/r-apt:0": { 12 | "vscodeRSupport": "full", 13 | "installDevTools": true, 14 | "installRMarkdown": true, 15 | "installRadian": true, 16 | "installVscDebugger": true, 17 | "installBspm": true, 18 | } 19 | }, 20 | 21 | // Use 'forwardPorts' to make a list of ports inside the container available locally. 22 | // "forwardPorts": [], 23 | 24 | // Use 'postCreateCommand' to run commands after the container is created. 25 | // "postCreateCommand": "R -q -e 'install.packages(\"tidyverse\")'", 26 | 27 | // Configure tool-specific properties. 28 | "customizations": { 29 | // Settings for VS Code. 30 | "vscode": { 31 | "extensions": [ 32 | "RDebugger.r-debugger" 33 | ], 34 | "settings": { 35 | "r.rterm.linux": "/usr/local/bin/radian", 36 | "r.bracketedPaste": true, 37 | "r.plot.useHttpgd": true 38 | } 39 | } 40 | }, 41 | 42 | // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. 43 | // "remoteUser": "root" 44 | } 45 | -------------------------------------------------------------------------------- /src/r2u/.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for more information: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | # https://containers.dev/guide/dependabot 6 | 7 | version: 2 8 | updates: 9 | - package-ecosystem: "devcontainers" 10 | directory: "/" 11 | schedule: 12 | interval: weekly 13 | -------------------------------------------------------------------------------- /src/r2u/NOTES.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## About the base image 4 | 5 | Please check . 6 | 7 | ## Install R packages 8 | 9 | Since `bspm` is enabled, the binary R packages (from `r2u` repository) and system dependencies can be installed 10 | via the `install.package` R function. 11 | 12 | ## Use [RStudio Server](https://posit.co/products/open-source/rstudio-server/) 13 | 14 | [The `ghcr.io/rocker-org/devcontainer-features/rstudio-server` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/rstudio-server) 15 | can be used to install and configure RStudio Server. 16 | 17 | ```jsonc 18 | "features": { 19 | "ghcr.io/rocker-org/devcontainer-features/r-apt:0": { 20 | "vscodeRSupport": "full", 21 | "installDevTools": true, 22 | "installRMarkdown": true, 23 | "installRadian": true, 24 | "installVscDebugger": true, 25 | "installBspm": true, 26 | }, 27 | "ghcr.io/rocker-org/devcontainer-features/rstudio-server:latest": {} // This line 28 | } 29 | ``` 30 | 31 | ## Use [Jupyter](https://jupyter.org/) 32 | 33 | The `InstallJupyterlab` option of 34 | [the `ghcr.io/rocker-org/devcontainer-features/r-apt` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/r-apt) 35 | can be used to install `jupyterlab` and `IRkernel`. 36 | 37 | Only add `"installJupyterlab": true` to `devcontainer.json` like below. 38 | 39 | ```jsonc 40 | "ghcr.io/rocker-org/devcontainer-features/r-apt:0": { 41 | "vscodeRSupport": "full", 42 | "installDevTools": true, 43 | "installRMarkdown": true, 44 | "installRadian": true, 45 | "installVscDebugger": true, 46 | "installBspm": true, 47 | "installJupyterlab": true // This line 48 | } 49 | ``` 50 | 51 | ## Make R console history persistent 52 | 53 | Normally the R console history is lost when we recreate the container, 54 | but we can preserve the history with 55 | [The `ghcr.io/rocker-org/devcontainer-features/r-history` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/r-history). 56 | 57 | ```jsonc 58 | "features": { 59 | "ghcr.io/rocker-org/devcontainer-features/r-apt:0": { 60 | "vscodeRSupport": "full", 61 | "installDevTools": true, 62 | "installRMarkdown": true, 63 | "installRadian": true, 64 | "installVscDebugger": true, 65 | "installBspm": true, 66 | }, 67 | "ghcr.io/rocker-org/devcontainer-features/r-history:0": {} // This line 68 | } 69 | ``` 70 | -------------------------------------------------------------------------------- /src/r2u/README.md: -------------------------------------------------------------------------------- 1 | 2 | # R (r2u and bspm configured) (r2u) 3 | 4 | Install R on Ubuntu and set r2u and bspm. 5 | 6 | ## Options 7 | 8 | | Options Id | Description | Type | Default Value | 9 | |-----|-----|-----|-----| 10 | | imageVariant | Ubuntu version: | string | noble | 11 | 12 | 13 | 14 | ## About the base image 15 | 16 | Please check . 17 | 18 | ## Install R packages 19 | 20 | Since `bspm` is enabled, the binary R packages (from `r2u` repository) and system dependencies can be installed 21 | via the `install.package` R function. 22 | 23 | ## Use [RStudio Server](https://posit.co/products/open-source/rstudio-server/) 24 | 25 | [The `ghcr.io/rocker-org/devcontainer-features/rstudio-server` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/rstudio-server) 26 | can be used to install and configure RStudio Server. 27 | 28 | ```jsonc 29 | "features": { 30 | "ghcr.io/rocker-org/devcontainer-features/r-apt:0": { 31 | "vscodeRSupport": "full", 32 | "installDevTools": true, 33 | "installRMarkdown": true, 34 | "installRadian": true, 35 | "installVscDebugger": true, 36 | "installBspm": true, 37 | }, 38 | "ghcr.io/rocker-org/devcontainer-features/rstudio-server:latest": {} // This line 39 | } 40 | ``` 41 | 42 | ## Use [Jupyter](https://jupyter.org/) 43 | 44 | The `InstallJupyterlab` option of 45 | [the `ghcr.io/rocker-org/devcontainer-features/r-apt` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/r-apt) 46 | can be used to install `jupyterlab` and `IRkernel`. 47 | 48 | Only add `"installJupyterlab": true` to `devcontainer.json` like below. 49 | 50 | ```jsonc 51 | "ghcr.io/rocker-org/devcontainer-features/r-apt:0": { 52 | "vscodeRSupport": "full", 53 | "installDevTools": true, 54 | "installRMarkdown": true, 55 | "installRadian": true, 56 | "installVscDebugger": true, 57 | "installBspm": true, 58 | "installJupyterlab": true // This line 59 | } 60 | ``` 61 | 62 | ## Make R console history persistent 63 | 64 | Normally the R console history is lost when we recreate the container, 65 | but we can preserve the history with 66 | [The `ghcr.io/rocker-org/devcontainer-features/r-history` Feature](https://github.com/rocker-org/devcontainer-features/tree/main/src/r-history). 67 | 68 | ```jsonc 69 | "features": { 70 | "ghcr.io/rocker-org/devcontainer-features/r-apt:0": { 71 | "vscodeRSupport": "full", 72 | "installDevTools": true, 73 | "installRMarkdown": true, 74 | "installRadian": true, 75 | "installVscDebugger": true, 76 | "installBspm": true, 77 | }, 78 | "ghcr.io/rocker-org/devcontainer-features/r-history:0": {} // This line 79 | } 80 | ``` 81 | 82 | 83 | --- 84 | 85 | _Note: This file was auto-generated from the [devcontainer-template.json](https://github.com/rocker-org/devcontainer-templates/blob/main/src/r2u/devcontainer-template.json). Add additional notes to a `NOTES.md`._ 86 | -------------------------------------------------------------------------------- /src/r2u/devcontainer-template.json: -------------------------------------------------------------------------------- 1 | { 2 | "id": "r2u", 3 | "version": "0.3.1", 4 | "name": "R (r2u and bspm configured)", 5 | "description": "Install R on Ubuntu and set r2u and bspm.", 6 | "documentationURL": "https://github.com/rocker-org/devcontainer-templates/tree/main/src/r2u", 7 | "publisher": "Rocker Project", 8 | "licenseURL": "https://github.com/rocker-org/devcontainer-templates/blob/main/LICENSE", 9 | "options": { 10 | "imageVariant": { 11 | "type": "string", 12 | "description": "Ubuntu version:", 13 | "proposals": [ 14 | "noble", 15 | "jammy" 16 | ], 17 | "default": "noble" 18 | } 19 | }, 20 | "platforms": [ 21 | "R" 22 | ], 23 | "optionalPaths": [ 24 | ".github/*" 25 | ] 26 | } 27 | -------------------------------------------------------------------------------- /test/r-ver/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd "$(dirname "$0")" || exit 3 | 4 | # shellcheck source=/dev/null 5 | source test-utils.sh 6 | 7 | check "R" R --version 8 | check "radian" radian --version 9 | check "languageserver" R -q -e 'packageVersion("languageserver")' 10 | check "httpgd" R -q -e 'packageVersion("httpgd")' 11 | check "rmarkdown" R -q -e 'packageVersion("rmarkdown")' 12 | check "devtools" R -q -e 'packageVersion("devtools")' 13 | check "pak" R -q -e 'packageVersion("pak")' 14 | check "renv" R -q -e 'packageVersion("renv")' 15 | check "vscDebugger" R -q -e 'packageVersion("vscDebugger")' 16 | 17 | # Report result 18 | reportResults 19 | -------------------------------------------------------------------------------- /test/r2u/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | cd "$(dirname "$0")" || exit 3 | 4 | # shellcheck source=/dev/null 5 | source test-utils.sh 6 | 7 | check "R" R --version 8 | check "radian" radian --version 9 | check "languageserver" R -q -e 'packageVersion("languageserver")' 10 | check "httpgd" R -q -e 'packageVersion("httpgd")' 11 | check "rmarkdown" R -q -e 'packageVersion("rmarkdown")' 12 | check "devtools" R -q -e 'packageVersion("devtools")' 13 | check "pak" R -q -e 'packageVersion("pak")' 14 | check "vscDebugger" R -q -e 'packageVersion("vscDebugger")' 15 | 16 | # Report result 17 | reportResults 18 | -------------------------------------------------------------------------------- /test/test-utils/test-utils.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | FAILED=() 4 | 5 | echoStderr() { 6 | echo "$@" 1>&2 7 | } 8 | 9 | check() { 10 | LABEL=$1 11 | shift 12 | echo -e "\n🧪 Testing $LABEL" 13 | if "$@"; then 14 | echo "✅ Passed!" 15 | return 0 16 | else 17 | echoStderr "❌ $LABEL check failed." 18 | FAILED+=("$LABEL") 19 | return 1 20 | fi 21 | } 22 | 23 | reportResults() { 24 | if [ ${#FAILED[@]} -ne 0 ]; then 25 | echoStderr -e "\n💥 Failed tests: ${FAILED[*]}" 26 | exit 1 27 | else 28 | echo -e "\n💯 All passed!" 29 | exit 0 30 | fi 31 | } 32 | --------------------------------------------------------------------------------