Create better caching of rosdep dependencies

For both  devcontainer and deployable container.
Also add ability to use docker from inside the devcontainer.
This commit is contained in:
Matt Spencer
2026-07-16 07:12:48 +00:00
parent 76701e81c0
commit f97df2273b
6 changed files with 123 additions and 14 deletions
+13 -14
View File
@@ -2,6 +2,7 @@ FROM osrf/ros:jazzy-desktop-full
ARG USERNAME=USERNAME
ARG USER_UID=1000
ARG USER_GID=$USER_UID
ARG TARGETARCH
# Delete user if it exists in container (e.g Ubuntu Noble: ubuntu)
RUN if id -u $USER_UID ; then userdel `id -un $USER_UID` ; fi
@@ -47,13 +48,18 @@ RUN apt-get update \
python3-vcstool \
&& rm -rf /var/lib/apt/lists/*
# Optional: pre-install apt dependencies resolved from rosdep on a previous run.
COPY .devcontainer/jazzy/ /tmp/devcontainer-jazzy/
RUN apt-get update \
&& if [ -f /tmp/devcontainer-jazzy/rosdep-apt-packages.txt ]; then \
grep -Ev '^\s*($|#)' /tmp/devcontainer-jazzy/rosdep-apt-packages.txt | xargs -r apt-get install -y --no-install-recommends; \
fi \
# system deps from frozen rosdep manifest — no rosdep at build or startup
# NOTE: There should be a check in your CI that this file is up to date.
# Something like:
# ./scripts/freeze-rosdep.sh && git diff --exit-code rosdep-packages.txt
COPY rosdep-packages.txt /tmp/rosdep-packages.txt
# The --mount=type=cache option caches the apt packages with buildkit
# The id-apt-cache-${TARGETARCH} option allows for separate caches for different architectures
# this enables parallel builds for different architectures without cache conflicts
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked,id=apt-cache-${TARGETARCH} \
rm -f /etc/apt/apt.conf.d/docker-clean \
&& apt-get update \
&& xargs -r -a /tmp/rosdep-packages.txt apt-get install -y --no-install-recommends \
&& rm -rf /var/lib/apt/lists/*
RUN apt-get update \
@@ -61,13 +67,6 @@ RUN apt-get update \
ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \
&& rm -rf /var/lib/apt/lists/*
# ROS 2 ament build tools
# RUN apt-get install -y \
# ros-${ROS_DISTRO}-ament-cmake \
# ros-${ROS_DISTRO}-ament-cmake-auto \
# ros-${ROS_DISTRO}-ament-python \
# ros-${ROS_DISTRO}-ament-lint-auto \
# ros-${ROS_DISTRO}-ament-lint-common
ENV SHELL=/bin/bash
@@ -0,0 +1,9 @@
{
"features": {
"ghcr.io/devcontainers/features/docker-from-docker:1": {
"version": "1.10.0",
"resolved": "ghcr.io/devcontainers/features/docker-from-docker@sha256:c2c2cf829505ead8e4892c88c31b6594ae94a2bbb209e16e1fac456c1a3a624e",
"integrity": "sha256:c2c2cf829505ead8e4892c88c31b6594ae94a2bbb209e16e1fac456c1a3a624e"
}
}
}
+6
View File
@@ -10,6 +10,12 @@
}
},
"workspaceFolder": "/workspaces/agv_pro_ros2",
"features": {
"ghcr.io/devcontainers/features/docker-from-docker:1": {
"version": "latest",
"moby": true
}
},
"customizations": {
"vscode": {
"extensions": [