Skip to content

Commit ae887b1

Browse files
authored
Mount overlay workspace into Dev Container via volume (#3524)
* 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
1 parent 3ae3c2a commit ae887b1

File tree

3 files changed

+18
-19
lines changed

3 files changed

+18
-19
lines changed

‎.devcontainer/devcontainer.json‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "Nav2",
3-
"build": {
4-
"dockerfile": "../Dockerfile",
3+
"build": {
4+
"dockerfile": "../Dockerfile",
55
"context": "..",
66
"target": "dever",
77
"cacheFrom": "ghcr.io/ros-planning/navigation2:main"
8-
},
8+
},
99
"runArgs": [
1010
"--privileged",
1111
"--network=host"
@@ -20,12 +20,17 @@
2020
"CCACHE_DIR": "/tmp/.ccache"
2121
},
2222
"mounts": [
23-
{
24-
"source": "ccache",
25-
"target": "/tmp/.ccache",
26-
"type": "volume"
27-
}
28-
],
23+
{
24+
"source": "ccache-${devcontainerId}",
25+
"target": "/tmp/.ccache",
26+
"type": "volume"
27+
},
28+
{
29+
"source": "overlay-${devcontainerId}",
30+
"target": "/opt/overlay_ws",
31+
"type": "volume"
32+
}
33+
],
2934
"features": {
3035
// "ghcr.io/devcontainers/features/desktop-lite:1": {},
3136
"ghcr.io/devcontainers/features/github-cli:1": {}

‎.devcontainer/on-create-command.sh‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ set -eo pipefail
77
# set -x
88
# env
99

10-
cd $OVERLAY_WS
11-
1210
git config --global --add safe.directory "*"
13-
colcon cache lock
1411

15-
. $UNDERLAY_WS/install/setup.sh
16-
colcon build \
17-
--symlink-install \
18-
--mixin $OVERLAY_MIXINS
12+
.devcontainer/update-content-command.sh

‎.devcontainer/update-content-command.sh‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ then
4949
fi
5050
echo BUILD_PACKAGES: $BUILD_PACKAGES
5151

52-
colcon clean packages --yes \
53-
--packages-select ${BUILD_PACKAGES} \
54-
--base-select install
52+
# colcon clean packages --yes \
53+
# --packages-select ${BUILD_PACKAGES} \
54+
# --base-select install
5555

5656
. $UNDERLAY_WS/install/setup.sh
5757
colcon build \

0 commit comments

Comments
 (0)