Skip to content

Commit

Permalink
Mount overlay workspace into Dev Container via volume (#3524)
Browse files Browse the repository at this point in the history
* Add volume for overlay
to avoid rebuilding it from scratch
whenever the dev container is rebuilt
this saves startup time locally when fiddling with the configs

* Append devcontainerId to volume name
to avoid conflicts with other devcontainers
note that devcontainerId is stable across rebuilds
- https://containers.dev/implementors/json_reference/#variables-in-devcontainerjson

* Call updateContentCommand from onCreateCommand
to deduplicate scripts and keep setup DRY
given the addition of a mounted overlay volume
which could include a prebuilt colcon workspace
well before the dev container is created/rebuilt

* Comment out colcon clean from setup
to avoid unintentional removal of built packages
from the persistent overlay workspace volume.
Users can uncomment the line locally
or simply remove the overlay workspace volume
if they want to rebuild packages from scratch.

* Format json
  • Loading branch information
ruffsl authored and SteveMacenski committed Jun 9, 2023
1 parent 7a25610 commit 1efcdcf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
23 changes: 14 additions & 9 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "Nav2",
"build": {
"dockerfile": "../Dockerfile",
"build": {
"dockerfile": "../Dockerfile",
"context": "..",
"target": "dever",
"cacheFrom": "ghcr.io/ros-planning/navigation2:main"
},
},
"runArgs": [
"--privileged",
"--network=host"
Expand All @@ -20,12 +20,17 @@
"CCACHE_DIR": "/tmp/.ccache"
},
"mounts": [
{
"source": "ccache",
"target": "/tmp/.ccache",
"type": "volume"
}
],
{
"source": "ccache-${devcontainerId}",
"target": "/tmp/.ccache",
"type": "volume"
},
{
"source": "overlay-${devcontainerId}",
"target": "/opt/overlay_ws",
"type": "volume"
}
],
"features": {
// "ghcr.io/devcontainers/features/desktop-lite:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
Expand Down
8 changes: 1 addition & 7 deletions .devcontainer/on-create-command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,6 @@ set -eo pipefail
# set -x
# env

cd $OVERLAY_WS

git config --global --add safe.directory "*"
colcon cache lock

. $UNDERLAY_WS/install/setup.sh
colcon build \
--symlink-install \
--mixin $OVERLAY_MIXINS
.devcontainer/update-content-command.sh
6 changes: 3 additions & 3 deletions .devcontainer/update-content-command.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ then
fi
echo BUILD_PACKAGES: $BUILD_PACKAGES

colcon clean packages --yes \
--packages-select ${BUILD_PACKAGES} \
--base-select install
# colcon clean packages --yes \
# --packages-select ${BUILD_PACKAGES} \
# --base-select install

. $UNDERLAY_WS/install/setup.sh
colcon build \
Expand Down

0 comments on commit 1efcdcf

Please sign in to comment.