summaryrefslogtreecommitdiff
path: root/docker-vyos/Dockerfile
diff options
context:
space:
mode:
authorKyrylo Yatsenko <hedrok@gmail.com>2025-06-21 22:42:58 +0300
committerKyrylo Yatsenko <hedrok@gmail.com>2025-06-22 12:57:54 +0300
commit92ff04087fb2e216aeadd86c9ca66605ac005e81 (patch)
treeea640894076fc30bd1083b31deb64043b1dc63a7 /docker-vyos/Dockerfile
parent3222553a260ae524a5c47801f4819a1825e999c2 (diff)
downloadvyos-build-92ff04087fb2e216aeadd86c9ca66605ac005e81.tar.gz
vyos-build-92ff04087fb2e216aeadd86c9ca66605ac005e81.zip
Docker: T7568: clean apt cache + clean some /tmp files
This saves ~50Mb for vyos-build image: 2.04Gb -> 1.99Gb And ~19Mb for vyos image: 155Mb -> 136Mb Docker stores all files created in each layer so command ``` RUN wget -O /tmp/open-vmdk-master.zip https://github.com/.../master.zip && \ unzip -d /tmp/ /tmp/open-vmdk-master.zip && \ cd /tmp/open-vmdk-master/ && make && make install ``` will store open-vmdk-master.zip and /tmp/open-vmdk-master in the image even though there is a cleanup command later: ``` RUN rm -rf /tmp/* ``` The cleanup command just makes these files invisible in last layer. So temporary file must be removed in same RUN command not to be stored in the image. This commit adds such removals.
Diffstat (limited to 'docker-vyos/Dockerfile')
-rw-r--r--docker-vyos/Dockerfile5
1 files changed, 5 insertions, 0 deletions
diff --git a/docker-vyos/Dockerfile b/docker-vyos/Dockerfile
index 0233817b..3fff371b 100644
--- a/docker-vyos/Dockerfile
+++ b/docker-vyos/Dockerfile
@@ -25,6 +25,8 @@ LABEL authors="VyOS Maintainers <maintainers@vyos.io>"
ENV DEBIAN_FRONTEND noninteractive
RUN /bin/echo -e 'APT::Install-Recommends "0";\nAPT::Install-Suggests "0";' > /etc/apt/apt.conf.d/01norecommends
+# Clean cache after each apt-get install command so that it is not stored in the image
+RUN /bin/echo -e 'DPkg::Post-Invoke {"/bin/rm -f /var/cache/apt/archives/*.deb /var/lib/apt/lists/* || true";};' > /etc/apt/apt.conf.d/clean
# Base packaged needed to build packages and their package dependencies
RUN apt-get update && apt-get install -y \
@@ -69,6 +71,9 @@ RUN bash /tmp/vyos_install_stage_03.sh
# Delete installer scripts
RUN rm -rf /tmp/*
+# Remove cleanup script so that in-container apt-get install uses cache
+RUN rm /etc/apt/apt.conf.d/clean
+
# Make changes specific to the container environment