Compare commits

...

4 Commits

Author SHA1 Message Date
Christian Breunig
3e5696d501
Merge pull request #979 from hedrok/docker-clean-apt-cache
Docker: T7568: clean apt cache + clean some /tmp files
2025-06-30 20:17:35 +02:00
Daniil Baturin
3a532c45a8
Merge pull request #983 from natali-rs1985/T7424-restart_vyos-configd
T7424: Restart vyos-configd after vyos.smoketests.hint file creation
2025-06-30 14:00:55 +01:00
Nataliia Solomko
4b1f3d4610 T7424: Restart vyos-configd after vyos.smoketests.hint file creation 2025-06-30 13:32:03 +03:00
Kyrylo Yatsenko
92ff04087f 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.
2025-06-22 12:57:54 +03:00
3 changed files with 22 additions and 6 deletions

View File

@ -25,6 +25,8 @@ LABEL authors="VyOS Maintainers <maintainers@vyos.io>"
ENV DEBIAN_FRONTEND noninteractive ENV DEBIAN_FRONTEND noninteractive
RUN /bin/echo -e 'APT::Install-Recommends "0";\nAPT::Install-Suggests "0";' > /etc/apt/apt.conf.d/01norecommends 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 # Base packaged needed to build packages and their package dependencies
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
@ -69,6 +71,9 @@ RUN bash /tmp/vyos_install_stage_03.sh
# Delete installer scripts # Delete installer scripts
RUN rm -rf /tmp/* 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 # Make changes specific to the container environment

View File

@ -53,6 +53,8 @@ LABEL authors="VyOS Maintainers <maintainers@vyos.io>" \
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
RUN /bin/echo -e 'APT::Install-Recommends "0";\nAPT::Install-Suggests "0";' > /etc/apt/apt.conf.d/01norecommends 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
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
dialog \ dialog \
@ -142,7 +144,8 @@ RUN dpkg-reconfigure ca-certificates; \
RUN curl https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh \ RUN curl https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh \
--output /tmp/opam_install.sh --retry 10 --retry-delay 5 && \ --output /tmp/opam_install.sh --retry 10 --retry-delay 5 && \
sed -i 's/read_tty BINDIR/BINDIR=""/' /tmp/opam_install.sh && sh /tmp/opam_install.sh && \ sed -i 's/read_tty BINDIR/BINDIR=""/' /tmp/opam_install.sh && sh /tmp/opam_install.sh && \
opam init --root=/opt/opam --comp=${OCAML_VERSION} --disable-sandboxing --no-setup opam init --root=/opt/opam --comp=${OCAML_VERSION} --disable-sandboxing --no-setup \
&& rm /tmp/opam_install.sh
RUN eval $(opam env --root=/opt/opam --set-root) && opam install -y \ RUN eval $(opam env --root=/opt/opam --set-root) && opam install -y \
re \ re \
@ -162,7 +165,8 @@ RUN apt-get update && apt-get install -y \
# Install open-vmdk # Install open-vmdk
RUN wget -O /tmp/open-vmdk-master.zip https://github.com/vmware/open-vmdk/archive/master.zip && \ RUN wget -O /tmp/open-vmdk-master.zip https://github.com/vmware/open-vmdk/archive/master.zip && \
unzip -d /tmp/ /tmp/open-vmdk-master.zip && \ unzip -d /tmp/ /tmp/open-vmdk-master.zip && \
cd /tmp/open-vmdk-master/ && make && make install cd /tmp/open-vmdk-master/ && make && make install && \
cd /tmp && rm -rf /tmp/open-vmdk-master/ && rm /tmp/open-vmdk-master.zip
# Packages need for build live-build # Packages need for build live-build
RUN apt-get update && apt-get install -y \ RUN apt-get update && apt-get install -y \
@ -175,7 +179,9 @@ RUN git clone https://salsa.debian.org/live-team/live-build.git /tmp/live-build
patch -p1 < /tmp/0001-save-package-info.patch && \ patch -p1 < /tmp/0001-save-package-info.patch && \
dch -n "Applying fix for save package info" && \ dch -n "Applying fix for save package info" && \
dpkg-buildpackage -us -uc && \ dpkg-buildpackage -us -uc && \
dpkg -i ../live-build*.deb dpkg -i ../live-build*.deb && \
rm -rf /tmp/live-build
# #
# live-build: building in docker fails with mounting /proc | /sys # live-build: building in docker fails with mounting /proc | /sys
# #
@ -190,13 +196,15 @@ RUN wget https://salsa.debian.org/klausenbusk-guest/debootstrap/commit/a9a603b17
patch -p1 < /tmp/a9a603b17cadbf52cb98cde0843dc9f23a08b0da.patch && \ patch -p1 < /tmp/a9a603b17cadbf52cb98cde0843dc9f23a08b0da.patch && \
dch -n "Applying fix for docker image compile" && \ dch -n "Applying fix for docker image compile" && \
dpkg-buildpackage -us -uc && \ dpkg-buildpackage -us -uc && \
sudo dpkg -i ../debootstrap*.deb sudo dpkg -i ../debootstrap*.deb \
&& rm /tmp/a9a603b17cadbf52cb98cde0843dc9f23a08b0da.patch \
&& rm -rf /tmp/debootstrap
# FPM is used when generation Debian pckages for e.g. Intel QAT drivers # FPM is used when generation Debian pckages for e.g. Intel QAT drivers
RUN gem install --no-document fpm RUN gem install --no-document fpm
# Packages needed for vyos-1x # Packages needed for vyos-1x
RUN pip install --break-system-packages \ RUN pip --no-cache --no-cache-dir install --break-system-packages \
git+https://github.com/aristanetworks/j2lint.git@341b5d5db86 \ git+https://github.com/aristanetworks/j2lint.git@341b5d5db86 \
pyhumps==3.8.0; \ pyhumps==3.8.0; \
apt-get update && apt-get install -y \ apt-get update && apt-get install -y \
@ -323,6 +331,9 @@ RUN sed -i 's/UID_MAX\t\t\t60000/UID_MAX\t\t\t2000000000/g' /etc/login.defs
# Cleanup # Cleanup
RUN rm -rf /tmp/* RUN rm -rf /tmp/*
# Remove cleanup script so that in-container apt-get install uses cache
RUN rm /etc/apt/apt.conf.d/clean
# Disable mouse in vim # Disable mouse in vim
RUN printf "set mouse=\nset ttymouse=\n" > /etc/vim/vimrc.local RUN printf "set mouse=\nset ttymouse=\n" > /etc/vim/vimrc.local

View File

@ -540,7 +540,7 @@ try:
# Start/stop config daemon # Start/stop config daemon
################################################# #################################################
if args.configd: if args.configd:
c.sendline('sudo systemctl start vyos-configd.service &> /dev/null') c.sendline('sudo systemctl restart vyos-configd.service &> /dev/null')
else: else:
c.sendline('sudo systemctl stop vyos-configd.service &> /dev/null') c.sendline('sudo systemctl stop vyos-configd.service &> /dev/null')
c.expect(op_mode_prompt) c.expect(op_mode_prompt)