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
5 changes: 5 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ghcr.io/carpentries/workbench-docker:latest

## this could be used to run userland scripts e.g.
## users could add specific dependencies or configurations
## RUN scripts/userland.sh
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
45 changes: 45 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"forwardPorts": [
8787,
4321
],
"portsAttributes": {
"8787": {
"label": "RStudio Server",
"onAutoForward": "notify"
},
"4321": {
"label": "Sandpaper Serve",
"onAutoForward": "notify"
}
},
"remoteUser":"rstudio",
"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"
],
"build": {
"dockerfile": "Dockerfile",
"context": ".."
},
"runArgs": [
"-p=8787:8787",
"-p=4321:4321"
],
"postCreateCommand": {
"pre_echo": "echo 'Installing lesson prerequisites - please wait...'",
"gpg_reset": "gpgconf --kill all",
"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",
"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"
}
}