From 05a6bdfc0affe6ee50733399e169fc4c32db3589 Mon Sep 17 00:00:00 2001
From: Andres Montano <andres.montano@tecnalia.com>
Date: Fri, 24 Jan 2025 15:09:17 +0100
Subject: [PATCH] Fix remove lists to reduce image size

---
 dockerfiles/devenv.Dockerfile | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/dockerfiles/devenv.Dockerfile b/dockerfiles/devenv.Dockerfile
index 64c92ce..955d1af 100644
--- a/dockerfiles/devenv.Dockerfile
+++ b/dockerfiles/devenv.Dockerfile
@@ -60,7 +60,8 @@ RUN apt-get update && \
     trash-cli \
     valgrind \
     wget \
-    xterm
+    xterm \
+    && rm -rf /var/lib/apt/lists/*
 
 # Install zsh if requested
 RUN if [ "$EXT_SHELL" = "zsh" ]; \
@@ -90,7 +91,7 @@ RUN if [ -f "${ROS_DISTRO}_requirements.txt" ]; \
     # workaround for ROS jazzy
     export PIP_BREAK_SYSTEM_PACKAGES=1 && \
     awk '/^# PIP PACKAGES/,0' ${ROS_DISTRO}_requirements.txt | grep -v '^#' | xargs -r -n1 pip install -U ;\
-    apt-get clean; \
+    apt-get clean; rm -rf /var/lib/apt/lists/*; \
     fi
 
 # Install extra libs from .deb files
@@ -107,14 +108,15 @@ RUN if [ -f "common_libs.txt" ]; \
     fi
 
 # Install notify-osd
-RUN apt-get --reinstall install -y libnotify-bin notify-osd
+RUN apt-get update && apt-get --reinstall install -y libnotify-bin notify-osd
 RUN rm -rf *
 
 # Update base image
 RUN apt-get update \
     && apt-get -y upgrade \
     && apt-get -y autoremove \
-    && apt-get -y autoclean
+    && apt-get -y autoclean \
+    && rm -rf /var/lib/apt/lists/*
 
 # Copy entrypoint
 COPY ./ros_entrypoint.sh /
@@ -180,6 +182,7 @@ RUN if [ "$PEAK_DRIVER" = "install" ]; \
     && tar -xvf PCAN-Basic_Linux.tar.gz \
     && cd PCAN-Basic_Linux-4.9.0.7/libpcanbasic \
     && make clean && make install || echo 'make failed but move forward';\
+    rm -rf /var/lib/apt/lists/*; \
     fi
 
 # Install conan for Kortex driver
@@ -212,7 +215,8 @@ LABEL image.date=09-01-2025
 RUN apt-get update \
     && apt-get -y upgrade \
     && apt-get -y autoremove \
-    && apt-get -y autoclean
+    && apt-get -y autoclean \
+    && rm -rf /var/lib/apt/lists/*
 
 # Switch back to dialog for any ad-hoc use of apt-get
 ENV DEBIAN_FRONTEND=
-- 
GitLab