Skip to content
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
20 changes: 20 additions & 0 deletions .devcontainer/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash
set -euo pipefail
set -x

GRO=$(git remote get-url origin)
ORG=$(dirname ${GRO} | awk -F':' '{ print $2 }')
REPO=$(basename -s .git ${GRO})
DEPS_IMG="ghcr.io/${ORG}/${REPO,,}-deps:latest"

if [[ ! -d "renv" ]]; then
echo "No renv directory found, using minimal image..."
DEPS_IMG="ghcr.io/carpentries/workbench-docker:latest-minimal"
sed -i "s|^FROM .*|FROM $DEPS_IMG|" .devcontainer/Dockerfile
elif docker pull "$DEPS_IMG"; then
echo "Using: ${DEPS_IMG}"
# update the Dockerfile FROM
sed -i "s|^FROM .*|FROM $DEPS_IMG|" .devcontainer/Dockerfile
fi

devcontainer up
29 changes: 22 additions & 7 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,21 @@
{
"forwardPorts": [8787],
"forwardPorts": [
8787,
4321
],
"portsAttributes": {
"8787": {
"label": "RStudio Server",
"onAutoForward": "notify"
},
"4321": {
"label": "Sandpaper Serve",
"onAutoForward": "notify"
}
},
"remoteUser":"rstudio",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/rstudio/lessons/${localWorkspaceFolderBasename},type=bind",
"workspaceFolder": "/home/rstudio/lessons/${localWorkspaceFolderBasename}",
"workspaceMount": "source=${localWorkspaceFolder},target=/home/rstudio/lesson,type=bind",
"workspaceFolder": "/home/rstudio/lesson",
"mounts": [
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.ssh,target=/home/rstudio/.ssh,type=bind,consistency=cached",
"source=${localEnv:HOME}${localEnv:USERPROFILE}/.gnupg,target=/home/rstudio/.gnupg,type=bind,consistency=cached"
Expand All @@ -17,14 +24,22 @@
"dockerfile": "Dockerfile",
"context": ".."
},
"runArgs": [
"-p=8787:8787",
"-p=4321:4321"
],
"postCreateCommand": {
"pre_echo": "echo 'Installing lesson prerequisites - please wait...'",
"gpg_reset": "gpgconf --kill all",
"lesson_deps": "Rscript /home/rstudio/.workbench/setup_lesson_deps.R",
"fortify": "Rscript /home/rstudio/.workbench/fortify_renv_cache.R"
"renv_rstudio_setup": "Rscript /home/rstudio/.workbench/fortify_renv_cache.R && bash /home/rstudio/start.sh"
},
"containerEnv": {
"DISABLE_AUTH": "true",
"GPG_TTY": "/dev/pts/0"
"GPG_TTY": "/dev/pts/0",
"USER": "rstudio",
"PASSWORD": "rstudio",
"RENV_PATHS_ROOT": "/home/rstudio/.local/share/renv",
"RENV_PROFILE": "lesson-requirements",
"RENV_CONFIG_EXTERNAL_LIBRARIES": "/usr/local/lib/R/site-library"
}
}
}