-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial .devcontainer config for codespaces (#6)
* Initial .devcontainer config for codespaces * Change features install order * Add installAfter setting renv cache. * Remove version from installAfter. * Use overrideFeatureInstallOrder as installsAfter is for feature.json * Handling CA certificates for devcontainer * Fix for arm64 devcontainer build. * Update 4.2 and 4.1 * Add codespaces config for multi repository access. * Clean postAttachCommand command. * Fix typo
- Loading branch information
Showing
13 changed files
with
372 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ | ||
// https://containers.dev/implementors/json_reference/ | ||
"name": "sdtm.oak (RStudio) container", | ||
"image": "ghcr.io/pharmaverse/sdtm.oak-4.1:latest", | ||
// Install Dev Container Features. More info: https://containers.dev/features | ||
"containerEnv": { | ||
"ROOT": "true", | ||
"PASSWORD": "rstudio", | ||
"DISABLE_AUTH": "true", | ||
"RENV_AUTOLOADER_ENABLED": "false" | ||
}, | ||
"features": { | ||
"./ca-cert": {}, | ||
"ghcr.io/rocker-org/devcontainer-features/r-rig:1": { | ||
"version": "none", | ||
"vscodeRSupport": "full", | ||
"installRadian": true, | ||
"installVscDebugger": true | ||
}, | ||
"ghcr.io/rocker-org/devcontainer-features/renv-cache:latest": {}, | ||
"ghcr.io/devcontainers/features/common-utils:2": { | ||
"installZsh": true, | ||
"configureZshAsDefaultShell": false, | ||
"installOhMyZsh": true, | ||
"username": "rstudio", | ||
"upgradePackages": false | ||
}, | ||
"ghcr.io/mikaello/devcontainer-features/modern-shell-utils:1": {} | ||
}, | ||
"overrideFeatureInstallOrder": [ | ||
"./ca-cert", | ||
"./arm64-repos", | ||
"ghcr.io/devcontainers/features/common-utils", | ||
"ghcr.io/rocker-org/devcontainer-features/renv-cache", | ||
"ghcr.io/rocker-org/devcontainer-features/r-rig", | ||
"ghcr.io/mikaello/devcontainer-features/modern-shell-utils" | ||
], | ||
"init": true, | ||
"overrideCommand": false, | ||
|
||
"postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh", | ||
|
||
"postAttachCommand": "rstudio || true", | ||
|
||
"customizations": { | ||
"codespaces": { | ||
"repositories": { | ||
"pharmaverse/mint": { | ||
"permissions": "write-all" | ||
}, | ||
"pharmaverse/raw.synthetic.data": { | ||
"permissions": "write-all" | ||
} | ||
} | ||
}, | ||
"vscode": { | ||
"settings": { | ||
"r.rterm.linux": "/usr/local/bin/radian", | ||
"r.bracketedPaste": true, | ||
"editor.bracketPairColorization.enabled": true, | ||
"editor.guides.bracketPairs": "active" | ||
}, | ||
"extensions": [ | ||
"vsls-contrib.codetour", | ||
"GitHub.copilot", | ||
"GitHub.copilot-chat", | ||
// R extensions | ||
"ikuyadeu.r", | ||
"REditorSupport.r-lsp", | ||
// Extra extension | ||
"streetsidesoftware.code-spell-checker", | ||
"eamodio.gitlens", | ||
"cweijan.vscode-office", | ||
"donjayamanne.githistory", | ||
"GitHub.vscode-github-actions", | ||
"GitHub.vscode-pull-request-github", | ||
"GitHub.remotehub", | ||
"alefragnani.Bookmarks", | ||
"vscode-icons-team.vscode-icons" | ||
] | ||
} | ||
}, | ||
|
||
// RStudio ports | ||
"forwardPorts": [8787], | ||
"portsAttributes": { | ||
"8787": { | ||
"label": "Rstudio", | ||
"requireLocalPort": true, | ||
"onAutoForward": "openBrowser" | ||
} | ||
}, | ||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root | ||
"remoteUser": "rstudio" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
{ | ||
// https://containers.dev/implementors/json_reference/ | ||
"name": "sdtm.oak R-4.2 (RStudio) container", | ||
"image": "ghcr.io/pharmaverse/sdtm.oak-4.2:latest", | ||
// Install Dev Container Features. More info: https://containers.dev/features | ||
"containerEnv": { | ||
"ROOT": "true", | ||
"PASSWORD": "rstudio", | ||
"DISABLE_AUTH": "true", | ||
"RENV_AUTOLOADER_ENABLED": "false" | ||
}, | ||
"features": { | ||
"./ca-cert": {}, | ||
"ghcr.io/rocker-org/devcontainer-features/r-rig:1": { | ||
"version": "none", | ||
"vscodeRSupport": "full", | ||
"installRadian": true, | ||
"installVscDebugger": true | ||
}, | ||
"ghcr.io/rocker-org/devcontainer-features/renv-cache:latest": {}, | ||
"ghcr.io/devcontainers/features/common-utils:2": { | ||
"installZsh": true, | ||
"configureZshAsDefaultShell": false, | ||
"installOhMyZsh": true, | ||
"username": "rstudio", | ||
"upgradePackages": false | ||
}, | ||
"ghcr.io/mikaello/devcontainer-features/modern-shell-utils:1": {} | ||
}, | ||
"overrideFeatureInstallOrder": [ | ||
"./ca-cert", | ||
"./arm64-repos", | ||
"ghcr.io/devcontainers/features/common-utils", | ||
"ghcr.io/rocker-org/devcontainer-features/renv-cache", | ||
"ghcr.io/rocker-org/devcontainer-features/r-rig", | ||
"ghcr.io/mikaello/devcontainer-features/modern-shell-utils" | ||
], | ||
"init": true, | ||
"overrideCommand": false, | ||
|
||
"postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh", | ||
|
||
"postAttachCommand": "rstudio || true", | ||
|
||
"customizations": { | ||
"codespaces": { | ||
"repositories": { | ||
"pharmaverse/mint": { | ||
"permissions": "write-all" | ||
}, | ||
"pharmaverse/raw.synthetic.data": { | ||
"permissions": "write-all" | ||
} | ||
} | ||
}, | ||
"vscode": { | ||
"settings": { | ||
"r.rterm.linux": "/usr/local/bin/radian", | ||
"r.bracketedPaste": true, | ||
"editor.bracketPairColorization.enabled": true, | ||
"editor.guides.bracketPairs": "active" | ||
}, | ||
"extensions": [ | ||
"vsls-contrib.codetour", | ||
"GitHub.copilot", | ||
"GitHub.copilot-chat", | ||
// R extensions | ||
"ikuyadeu.r", | ||
"REditorSupport.r-lsp", | ||
// Extra extension | ||
"streetsidesoftware.code-spell-checker", | ||
"eamodio.gitlens", | ||
"cweijan.vscode-office", | ||
"donjayamanne.githistory", | ||
"GitHub.vscode-github-actions", | ||
"GitHub.vscode-pull-request-github", | ||
"GitHub.remotehub", | ||
"alefragnani.Bookmarks", | ||
"vscode-icons-team.vscode-icons" | ||
] | ||
} | ||
}, | ||
|
||
// RStudio ports | ||
"forwardPorts": [8787], | ||
"portsAttributes": { | ||
"8787": { | ||
"label": "Rstudio", | ||
"requireLocalPort": true, | ||
"onAutoForward": "openBrowser" | ||
} | ||
}, | ||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root | ||
"remoteUser": "rstudio" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "arm64 repos", | ||
"id": "arm64-repos", | ||
"version": "0.1.0", | ||
"description": "Fix repos for arm64.", | ||
"options": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
ARCH=$(uname -m) | ||
|
||
## source install if using RSPM and arm64 image | ||
if [ "$ARCH" = "aarch64" ]; then | ||
|
||
CRAN="https://cloud.r-project.org" | ||
|
||
## Add a default CRAN mirror | ||
echo "options(repos = c(CRAN = '${CRAN}'), download.file.method = 'libcurl')" >"${R_HOME}/etc/Rprofile.site" | ||
|
||
## Set HTTPUserAgent for RSPM (https://github.com/rocker-org/rocker/issues/400) | ||
cat <<EOF >>"${R_HOME}/etc/Rprofile.site" | ||
# https://docs.rstudio.com/rspm/admin/serving-binaries/#binaries-r-configuration-linux | ||
options(HTTPUserAgent = sprintf("R/%s R (%s)", getRversion(), paste(getRversion(), R.version["platform"], R.version["arch"], R.version["os"]))) | ||
EOF | ||
|
||
fi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.crt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "CA cert", | ||
"id": "ca-cert", | ||
"version": "0.1.0", | ||
"description": "Copy CA cert into the container.", | ||
"options": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/sh | ||
|
||
set -e | ||
|
||
# Copy CA certificate to `/etc/ssl/cert` | ||
if ls *.crt 1> /dev/null 2>&1; then | ||
sudo cp *.crt /usr/local/share/ca-certificates | ||
sudo update-ca-certificates | ||
fi | ||
|
||
echo "Done!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{ | ||
// https://containers.dev/implementors/json_reference/ | ||
"name": "sdtm.oak R-4.3 (RStudio) container", | ||
"image": "ghcr.io/pharmaverse/sdtm.oak-4.3:latest", | ||
// Install Dev Container Features. More info: https://containers.dev/features | ||
"containerEnv": { | ||
"ROOT": "true", | ||
"PASSWORD": "rstudio", | ||
"DISABLE_AUTH": "true", | ||
"RENV_AUTOLOADER_ENABLED": "false" | ||
}, | ||
"features": { | ||
"./ca-cert": {}, | ||
"./arm64-repos": {}, | ||
"ghcr.io/rocker-org/devcontainer-features/r-rig:1": { | ||
"version": "none", | ||
"vscodeRSupport": "full", | ||
"installRadian": true, | ||
"installVscDebugger": true | ||
}, | ||
"ghcr.io/rocker-org/devcontainer-features/renv-cache:latest": {}, | ||
"ghcr.io/devcontainers/features/common-utils:2": { | ||
"installZsh": true, | ||
"configureZshAsDefaultShell": false, | ||
"installOhMyZsh": true, | ||
"username": "rstudio", | ||
"upgradePackages": false | ||
}, | ||
"ghcr.io/mikaello/devcontainer-features/modern-shell-utils:1": {} | ||
}, | ||
"overrideFeatureInstallOrder": [ | ||
"./ca-cert", | ||
"./arm64-repos", | ||
"ghcr.io/devcontainers/features/common-utils", | ||
"ghcr.io/rocker-org/devcontainer-features/renv-cache", | ||
"ghcr.io/rocker-org/devcontainer-features/r-rig", | ||
"ghcr.io/mikaello/devcontainer-features/modern-shell-utils" | ||
], | ||
"init": true, | ||
"overrideCommand": false, | ||
|
||
"postCreateCommand": "bash ./.devcontainer/postCreateCommand.sh", | ||
|
||
"postAttachCommand": "rstudio || true", | ||
|
||
"customizations": { | ||
"codespaces": { | ||
"repositories": { | ||
"pharmaverse/mint": { | ||
"permissions": "read-all" | ||
}, | ||
"pharmaverse/raw.synthetic.data": { | ||
"permissions": "read-all" | ||
} | ||
} | ||
}, | ||
"vscode": { | ||
"settings": { | ||
"r.rterm.linux": "/usr/local/bin/radian", | ||
"r.bracketedPaste": true, | ||
"editor.bracketPairColorization.enabled": true, | ||
"editor.guides.bracketPairs": "active" | ||
}, | ||
"extensions": [ | ||
"vsls-contrib.codetour", | ||
"GitHub.copilot", | ||
"GitHub.copilot-chat", | ||
// R extensions | ||
"ikuyadeu.r", | ||
"REditorSupport.r-lsp", | ||
// Extra extension | ||
"streetsidesoftware.code-spell-checker", | ||
"eamodio.gitlens", | ||
"cweijan.vscode-office", | ||
"donjayamanne.githistory", | ||
"GitHub.vscode-github-actions", | ||
"GitHub.vscode-pull-request-github", | ||
"GitHub.remotehub", | ||
"alefragnani.Bookmarks", | ||
"vscode-icons-team.vscode-icons" | ||
] | ||
} | ||
}, | ||
|
||
// RStudio ports | ||
"forwardPorts": [8787], | ||
"portsAttributes": { | ||
"8787": { | ||
"label": "Rstudio", | ||
"requireLocalPort": true, | ||
"onAutoForward": "openBrowser" | ||
} | ||
}, | ||
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root | ||
"remoteUser": "rstudio" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
# move script rstudio into /usr/bin | ||
sudo cp "$(pwd)/.devcontainer/rstudio.sh" /usr/bin/rstudio | ||
sudo chmod +x /usr/bin/rstudio | ||
|
||
# Restore renv and install staged dependencies | ||
R -q -e 'renv::restore(lockfile = file.path("renv", "profiles", paste(R.version$major, substr(R.version$minor, 1, 1), sep = "."), "renv.lock")); staged.dependencies::install_deps(staged.dependencies::dependency_table(project = ".", verbose = 1), verbose = 1);' | ||
|
||
# Define rstudio default working directory | ||
jq --arg folder "$(pwd)/" '. + { "initial_working_directory": $folder }' .devcontainer/rstudio-prefs.json > ~/.config/rstudio/rstudio-prefs.json |
Oops, something went wrong.