Skip to content

Commit

Permalink
improve devcontainer setup
Browse files Browse the repository at this point in the history
add renv cache (volume)
restore renv on post create
  • Loading branch information
black-snow committed Jan 12, 2025
1 parent 3a82d9e commit 3244883
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
3 changes: 0 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ RUN apt update \
pandoc \
&& :

# install dev dependencies
RUN R -q -e 'install.packages("renv")'

WORKDIR /invertr

COPY . .
8 changes: 5 additions & 3 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"context": "..",
"runArgs": [
"--name",
"dev_invertr",
"dev_invallor",
"--init"
],
"customizations": {
Expand All @@ -18,13 +18,15 @@
}
},
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
"features": {
"ghcr.io/rocker-org/devcontainer-features/renv-cache:latest": {}
},

// 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 -q -e 'install.packages(\"devtools\")'"
"postCreateCommand": ".devcontainer/postcreate.sh"

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
Expand Down
5 changes: 5 additions & 0 deletions .devcontainer/postcreate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh
set -euo pipefail

R -q -e 'install.packages("devtools")'
R -q -e 'renv::restore()'

0 comments on commit 3244883

Please sign in to comment.