Skip to content

Commit f8af5fe

Browse files
committed
Merge branch 'cleanup-aptget' into remove-runtime
2 parents 673f546 + 49855ee commit f8af5fe

File tree

4 files changed

+51
-22
lines changed

4 files changed

+51
-22
lines changed

.clang-tidy

+3
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ WarningsAsErrors: "
202202

203203
HeaderFilterRegex: ^(?!\/usr)(?!\/opt)
204204

205+
ExtraArgs:
206+
- -std=c++17
207+
205208
FormatStyle: none
206209

207210
CheckOptions:

.clang-tidy-ci

+3
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@ WarningsAsErrors: "
225225

226226
HeaderFilterRegex: ^(?!\/usr)(?!\/opt)
227227

228+
ExtraArgs:
229+
- -std=c++17
230+
228231
CheckOptions:
229232
- key: bugprone-argument-comment.CommentBoolLiterals
230233
value: "0"

docker/Dockerfile

+34-22
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,32 @@ FROM $BASE_IMAGE AS base
55
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
66
ARG ROS_DISTRO
77

8+
# Copy files
9+
COPY setup-dev-env.sh ansible-galaxy-requirements.yaml amd64.env arm64.env /autoware/
10+
COPY ansible/ /autoware/ansible/
11+
COPY docker/scripts/cleanup_apt.sh /autoware/cleanup_apt.sh
12+
RUN chmod +x /autoware/cleanup_apt.sh
13+
COPY docker/scripts/cleanup_system.sh /autoware/cleanup_system.sh
14+
RUN chmod +x /autoware/cleanup_system.sh
15+
WORKDIR /autoware
16+
817
# Install apt packages and add GitHub to known hosts for private repositories
918
RUN rm -f /etc/apt/apt.conf.d/docker-clean \
1019
&& echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' >/etc/apt/apt.conf.d/keep-cache
1120
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
1221
apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install --no-install-recommends \
1322
gosu \
1423
ssh \
15-
&& apt-get autoremove -y && rm -rf "$HOME"/.cache \
24+
&& /autoware/cleanup_apt.sh \
1625
&& mkdir -p ~/.ssh \
1726
&& ssh-keyscan github.com >> ~/.ssh/known_hosts
1827

19-
# Copy files
20-
COPY setup-dev-env.sh ansible-galaxy-requirements.yaml amd64.env arm64.env /autoware/
21-
COPY ansible/ /autoware/ansible/
22-
COPY docker/scripts/cleanup_system.sh /autoware/cleanup_system.sh
23-
RUN chmod +x /autoware/cleanup_system.sh
24-
WORKDIR /autoware
25-
2628
# Set up base environment
2729
RUN --mount=type=ssh \
2830
--mount=type=cache,target=/var/cache/apt,sharing=locked \
2931
./setup-dev-env.sh -y --module base --no-nvidia --no-cuda-drivers --runtime openadkit \
3032
&& pip uninstall -y ansible ansible-core \
31-
&& apt-get autoremove -y && rm -rf "$HOME"/.cache \
33+
&& /autoware/cleanup_apt.sh \
3234
&& echo "source /opt/ros/${ROS_DISTRO}/setup.bash" > /etc/bash.bashrc
3335

3436
# Create entrypoint
@@ -45,7 +47,7 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
4547
RUN --mount=type=ssh \
4648
./setup-dev-env.sh -y --module base --download-artifacts --no-cuda-drivers --runtime openadkit \
4749
&& pip uninstall -y ansible ansible-core \
48-
&& apt-get autoremove -y && rm -rf "$HOME"/.cache
50+
&& /autoware/cleanup_apt.sh true
4951

5052
# hadolint ignore=DL3006
5153
FROM $BASE_IMAGE AS rosdep-depend
@@ -54,6 +56,8 @@ ARG ROS_DISTRO
5456

5557
COPY setup-dev-env.sh ansible-galaxy-requirements.yaml amd64.env arm64.env /autoware/
5658
COPY ansible/ /autoware/ansible/
59+
COPY docker/scripts/cleanup_apt.sh /autoware/cleanup_apt.sh
60+
RUN chmod +x /autoware/cleanup_apt.sh
5761
COPY docker/scripts/resolve_rosdep_keys.sh /autoware/resolve_rosdep_keys.sh
5862
RUN chmod +x /autoware/resolve_rosdep_keys.sh
5963
WORKDIR /autoware
@@ -64,7 +68,7 @@ RUN --mount=type=ssh \
6468
--mount=type=cache,target=/var/cache/apt,sharing=locked \
6569
./setup-dev-env.sh -y rosdep \
6670
&& pip uninstall -y ansible ansible-core \
67-
&& apt-get autoremove -y && rm -rf "$HOME"/.cache
71+
&& /autoware/cleanup_apt.sh
6872

6973
# Generate install package lists
7074
COPY src/core /autoware/src/core
@@ -169,15 +173,15 @@ RUN --mount=type=ssh \
169173
./setup-dev-env.sh -y --module all --no-nvidia --no-cuda-drivers openadkit \
170174
&& ./setup-dev-env.sh -y --module dev-tools openadkit \
171175
&& pip uninstall -y ansible ansible-core \
172-
&& apt-get autoremove -y && rm -rf "$HOME"/.cache
176+
&& /autoware/cleanup_apt.sh
173177

174178
# Install rosdep dependencies
175179
COPY --from=rosdep-depend /rosdep-core-depend-packages.txt /tmp/rosdep-core-depend-packages.txt
176180
# hadolint ignore=SC2002
177181
RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \
178182
apt-get update \
179183
&& cat /tmp/rosdep-core-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
180-
&& apt-get autoremove -y && rm -rf "$HOME"/.cache
184+
&& /autoware/cleanup_apt.sh
181185

182186
RUN --mount=type=cache,target=${CCACHE_DIR} \
183187
--mount=type=bind,from=rosdep-depend,source=/autoware/src/core,target=/autoware/src/core \
@@ -196,9 +200,10 @@ ENV CCACHE_DIR="/root/.ccache"
196200
COPY --from=rosdep-depend /rosdep-universe-common-depend-packages.txt /tmp/rosdep-universe-common-depend-packages.txt
197201
# hadolint ignore=SC2002
198202
RUN --mount=type=ssh \
203+
--mount=type=cache,target=/var/cache/apt,sharing=locked \
199204
apt-get update \
200205
&& cat /tmp/rosdep-universe-common-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
201-
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache
206+
&& /autoware/cleanup_apt.sh
202207

203208
# hadolint ignore=SC1091
204209
RUN --mount=type=cache,target=${CCACHE_DIR} \
@@ -219,7 +224,7 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
219224
RUN --mount=type=ssh \
220225
./setup-dev-env.sh -y --module all --no-cuda-drivers openadkit \
221226
&& pip uninstall -y ansible ansible-core \
222-
&& apt-get autoremove -y && rm -rf "$HOME"/.cache
227+
&& /autoware/cleanup_apt.sh true
223228

224229
ENTRYPOINT ["/ros_entrypoint.sh"]
225230
CMD ["/bin/bash"]
@@ -233,9 +238,10 @@ ENV CCACHE_DIR="/root/.ccache"
233238
COPY --from=rosdep-universe-sensing-perception-depend /rosdep-universe-sensing-perception-depend-packages.txt /tmp/rosdep-universe-sensing-perception-depend-packages.txt
234239
# hadolint ignore=SC2002
235240
RUN --mount=type=ssh \
241+
--mount=type=cache,target=/var/cache/apt,sharing=locked \
236242
apt-get update \
237243
&& cat /tmp/rosdep-universe-sensing-perception-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
238-
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache
244+
&& /autoware/cleanup_apt.sh
239245

240246
# hadolint ignore=SC1091
241247
RUN --mount=type=cache,target=${CCACHE_DIR} \
@@ -257,9 +263,10 @@ ENV CCACHE_DIR="/root/.ccache"
257263
COPY --from=rosdep-universe-sensing-perception-depend /rosdep-universe-sensing-perception-depend-packages.txt /tmp/rosdep-universe-sensing-perception-depend-packages.txt
258264
# hadolint ignore=SC2002
259265
RUN --mount=type=ssh \
266+
--mount=type=cache,target=/var/cache/apt,sharing=locked \
260267
apt-get update \
261268
&& cat /tmp/rosdep-universe-sensing-perception-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
262-
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache
269+
&& /autoware/cleanup_apt.sh
263270

264271
# hadolint ignore=SC1091
265272
RUN --mount=type=cache,target=${CCACHE_DIR} \
@@ -293,9 +300,10 @@ ENV CCACHE_DIR="/root/.ccache"
293300
COPY --from=rosdep-universe-localization-mapping-depend /rosdep-universe-localization-mapping-depend-packages.txt /tmp/rosdep-universe-localization-mapping-depend-packages.txt
294301
# hadolint ignore=SC2002
295302
RUN --mount=type=ssh \
303+
--mount=type=cache,target=/var/cache/apt,sharing=locked \
296304
apt-get update \
297305
&& cat /tmp/rosdep-universe-localization-mapping-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
298-
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache
306+
&& /autoware/cleanup_apt.sh
299307

300308
# hadolint ignore=SC1091
301309
RUN --mount=type=cache,target=${CCACHE_DIR} \
@@ -314,9 +322,10 @@ ENV CCACHE_DIR="/root/.ccache"
314322
COPY --from=rosdep-universe-planning-control-depend /rosdep-universe-planning-control-depend-packages.txt /tmp/rosdep-universe-planning-control-depend-packages.txt
315323
# hadolint ignore=SC2002
316324
RUN --mount=type=ssh \
325+
--mount=type=cache,target=/var/cache/apt,sharing=locked \
317326
apt-get update \
318327
&& cat /tmp/rosdep-universe-planning-control-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
319-
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache
328+
&& /autoware/cleanup_apt.sh
320329

321330
# hadolint ignore=SC1091
322331
RUN --mount=type=cache,target=${CCACHE_DIR} \
@@ -343,9 +352,10 @@ ENV CCACHE_DIR="/root/.ccache"
343352
COPY --from=rosdep-universe-vehicle-system-depend /rosdep-universe-vehicle-system-depend-packages.txt /tmp/rosdep-universe-vehicle-system-depend-packages.txt
344353
# hadolint ignore=SC2002
345354
RUN --mount=type=ssh \
355+
--mount=type=cache,target=/var/cache/apt,sharing=locked \
346356
apt-get update \
347357
&& cat /tmp/rosdep-universe-vehicle-system-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
348-
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache
358+
&& /autoware/cleanup_apt.sh
349359

350360
# hadolint ignore=SC1091
351361
RUN --mount=type=cache,target=${CCACHE_DIR} \
@@ -369,9 +379,10 @@ ENV CCACHE_DIR="/root/.ccache"
369379
COPY --from=rosdep-universe-depend /rosdep-universe-depend-packages.txt /tmp/rosdep-universe-depend-packages.txt
370380
# hadolint ignore=SC2002
371381
RUN --mount=type=ssh \
382+
--mount=type=cache,target=/var/cache/apt,sharing=locked \
372383
apt-get update \
373384
&& cat /tmp/rosdep-universe-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
374-
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache
385+
&& /autoware/cleanup_apt.sh
375386

376387
COPY --from=universe-sensing-perception-devel /opt/autoware /opt/autoware
377388
COPY --from=universe-localization-mapping-devel /opt/autoware /opt/autoware
@@ -402,9 +413,10 @@ SHELL ["/bin/bash", "-o", "pipefail", "-c"]
402413
COPY --from=rosdep-universe-depend /rosdep-universe-depend-packages.txt /tmp/rosdep-universe-depend-packages.txt
403414
# hadolint ignore=SC2002
404415
RUN --mount=type=ssh \
416+
--mount=type=cache,target=/var/cache/apt,sharing=locked \
405417
apt-get update \
406418
&& cat /tmp/rosdep-universe-depend-packages.txt | xargs apt-get install -y --no-install-recommends \
407-
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* "$HOME"/.cache
419+
&& /autoware/cleanup_apt.sh
408420

409421
COPY --from=universe-sensing-perception-devel-cuda /opt/autoware /opt/autoware
410422
COPY --from=universe-devel /opt/autoware /opt/autoware

docker/scripts/cleanup_apt.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
function cleanup() {
4+
local remove_var_lib_apt_lists=false
5+
apt-get autoremove -y && rm -rf "$HOME"/.cache
6+
if "$remove_var_lib_apt_lists"; then
7+
rm -rf /var/lib/apt/lists/*
8+
fi
9+
}
10+
11+
cleanup "$@"

0 commit comments

Comments
 (0)