Skip to content

Commit f439bf4

Browse files
committed
perf(template_ws): Speed up local docker build with cache mounts
Fixes: #41
1 parent 680d12d commit f439bf4

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

template_ws/docker/Dockerfile

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,22 @@ ARG USER_UID=1000
77

88
# Upgrade packages
99
# Ref: https://pythonspeed.com/articles/security-updates-in-docker/
10-
RUN apt-get update && apt-get upgrade -y \
10+
# Ref: https://docs.docker.com/build/cache/#use-the-dedicated-run-cache
11+
RUN --mount=type=cache,target=/var/cache/apt \
12+
apt-get update && apt-get upgrade -y \
1113
&& rm -rf /var/lib/apt/lists/*
1214

1315
# Install sudo and create a user with sudo privileges
1416
# Ref: https://stackoverflow.com/a/65434659
15-
RUN apt-get update && apt-get install -y sudo \
17+
RUN --mount=type=cache,target=/var/cache/apt \
18+
apt-get update && apt-get install -y sudo \
1619
&& useradd -m -s /bin/bash -u $USER_UID -G sudo $USERNAME \
1720
&& echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers \
1821
&& rm -rf /var/lib/apt/lists/*
1922

2023
# Install common tools
21-
RUN apt-get update && apt-get install -y \
24+
RUN --mount=type=cache,target=/var/cache/apt \
25+
apt-get update && apt-get install -y \
2226
curl \
2327
git \
2428
htop \
@@ -34,16 +38,19 @@ RUN apt-get update && apt-get install -y \
3438
&& rm -rf /var/lib/apt/lists/*
3539

3640
# Install Python pip
37-
RUN apt-get update && apt-get install -y python3-pip \
41+
RUN --mount=type=cache,target=/var/cache/apt \
42+
apt-get update && apt-get install -y \
3843
&& rm -rf /var/lib/apt/lists/*
3944

4045
# Install custom tools
41-
RUN apt-get update && apt-get install -y \
46+
RUN --mount=type=cache,target=/var/cache/apt \
47+
apt-get update && apt-get install -y \
4248
git-extras \
4349
&& rm -rf /var/lib/apt/lists/*
4450

4551
# Install ROS2 RVIZ and Gazebo
46-
RUN apt-get update && apt-get install -y \
52+
RUN --mount=type=cache,target=/var/cache/apt \
53+
apt-get update && apt-get install -y \
4754
ros-$ROS_DISTRO-gazebo-ros-pkgs \
4855
ros-$ROS_DISTRO-rviz2 \
4956
&& rm -rf /var/lib/apt/lists/*

0 commit comments

Comments
 (0)