Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Dev Container ergonomics #3482

Merged
merged 24 commits into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
133c7fe
Install and enable bash autocompletion
ruffsl Mar 16, 2023
8a174b4
Edit apt for autocomplete
ruffsl Mar 16, 2023
cf51a6d
Add ROS2 Ament Task Provider extension
ruffsl Mar 16, 2023
ef52162
Source underlay for extentions
ruffsl Mar 16, 2023
35baf2e
Target new dever stage in Dockerfile
ruffsl Mar 16, 2023
8d6e37f
Reduce need for internet after image build
ruffsl Mar 16, 2023
5f21398
Edit apt caching before apt updating
ruffsl Mar 16, 2023
438abce
Source underlay systemwide
ruffsl Mar 16, 2023
be795eb
Postpone bashrc setup to postCreateCommand
ruffsl Mar 16, 2023
8e13faf
Cleanup onCreateCommand
ruffsl Mar 16, 2023
ddbd44a
Quite down the logs when building devcontainer
ruffsl Mar 16, 2023
1922efb
Formatting
ruffsl Mar 16, 2023
f8ba46d
Add refrence ccp properties config file
ruffsl Mar 16, 2023
c150080
Update version of cppStandard for ROS Rolling
ruffsl Mar 16, 2023
6869b5c
Update workspaceFolder to use new .vscode folder
ruffsl Mar 16, 2023
81241a0
Mount ccache directory to volume
ruffsl Mar 16, 2023
dc6a058
Avoid use of containerEnv to express ccache direcotry
ruffsl Mar 16, 2023
555a8dc
Stage auto generated includePath
ruffsl Mar 17, 2023
5eb3a71
Remove workspace install from include path
ruffsl Mar 17, 2023
7797fff
Avoid hardcoded path to sorce folder
ruffsl Mar 17, 2023
002dd46
Avoid hardcoded path to install folder
ruffsl Mar 17, 2023
9135cbb
Sort list of paths
ruffsl Mar 17, 2023
c2d5671
Remove cpp properties configuration
ruffsl Mar 17, 2023
46e4798
Fix typo
ruffsl Mar 20, 2023
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
24 changes: 19 additions & 5 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,31 @@
{
"name": "Nav2",
"image": "ghcr.io/ros-planning/navigation2:main",
"build": {
"dockerfile": "../Dockerfile",
"context": "..",
"target": "dever",
"cacheFrom": "ghcr.io/ros-planning/navigation2:main"
},
"runArgs": [
"--privileged",
"--network=host"
],
"workspaceMount": "source=${localWorkspaceFolder},target=/opt/overlay_ws/src/navigation2,type=bind",
"workspaceFolder": "/opt/overlay_ws/src",
"onCreateCommand": "navigation2/.devcontainer/on-create-command.sh",
"updateContentCommand": "navigation2/.devcontainer/update-content-command.sh",
"workspaceFolder": "/opt/overlay_ws/src/navigation2",
"onCreateCommand": ".devcontainer/on-create-command.sh",
"updateContentCommand": ".devcontainer/update-content-command.sh",
"postCreateCommand": ".devcontainer/post-create-command.sh",
"remoteEnv": {
"OVERLAY_MIXINS": "release ccache lld",
"CCACHE_DIR": "${containerEnv:OVERLAY_WS}/.ccache"
"CCACHE_DIR": "/tmp/.ccache"
},
"mounts": [
{
"source": "ccache",
"target": "/tmp/.ccache",
"type": "volume"
}
],
"features": {
// "ghcr.io/devcontainers/features/desktop-lite:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
Expand All @@ -26,6 +39,7 @@
"vscode": {
"settings": {},
"extensions": [
"althack.ament-task-provider",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"GitHub.copilot",
Expand Down
13 changes: 6 additions & 7 deletions .devcontainer/on-create-command.sh
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
#!/bin/bash

set -exo pipefail
# Immediately catch all errors
set -eo pipefail

env
# Uncomment for debugging
# set -x
# env

cd $OVERLAY_WS
. $UNDERLAY_WS/install/setup.sh

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

. $UNDERLAY_WS/install/setup.sh
colcon build \
--symlink-install \
--mixin $OVERLAY_MIXINS

sed --in-place \
's|^source .*|source "$OVERLAY_WS/install/setup.bash"|' \
/ros_entrypoint.sh
11 changes: 11 additions & 0 deletions .devcontainer/post-create-command.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

# Immediately catch all errors
set -eo pipefail

# Uncomment for debugging
# set -x
# env

# Enable autocomplete for user
cp /etc/skel/.bashrc ~/
7 changes: 5 additions & 2 deletions .devcontainer/update-content-command.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#!/bin/bash

set -exo pipefail
# Immediately catch all errors
set -eo pipefail

env
# Uncomment for debugging
# set -x
# env

cd $OVERLAY_WS

Expand Down
14 changes: 14 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,20 @@ RUN . $UNDERLAY_WS/install/setup.sh && \
--ignore-src \
&& rm -rf /var/lib/apt/lists/*

# multi-stage for developing
FROM builder AS dever

# edit apt for caching
RUN mv /etc/apt/apt.conf.d/docker-clean /etc/apt/

# install developer dependencies
RUN apt-get update && \
apt-get install -y \
bash-completion

# source underlay for shell
RUN echo 'source "$UNDERLAY_WS/install/setup.bash"' >> /etc/bash.bashrc

# multi-stage for testing
FROM builder AS tester

Expand Down