Cleanup APT lists after installing packages

/var/lib/apt/lists/ can take several MBs so get rid of them after
packages are installed.

Change-Id: Icfff55d92fa5c865f09db5112da28bf452a5a221
This commit is contained in:
Christian Berendt 2017-10-04 15:54:08 +02:00 committed by Marcin Juszkiewicz
parent 93b91ceef6
commit 4de0706190
4 changed files with 18 additions and 7 deletions

View File

@ -268,7 +268,8 @@ COPY dpkg_reducing_disk_footprint /etc/dpkg/dpkg.cfg.d/dpkg_reducing_disk_footpr
# apt-get update will not work if any repositories are accessed via HTTPS # apt-get update will not work if any repositories are accessed via HTTPS
RUN apt-get update \ RUN apt-get update \
&& apt-get -y install --no-install-recommends apt-transport-https ca-certificates gnupg dirmngr curl \ && apt-get -y install --no-install-recommends apt-transport-https ca-certificates gnupg dirmngr curl \
&& apt-get clean && apt-get clean \
&& rm -rf /var/lib/apt/lists/*
{% endblock %} {% endblock %}
{% block base_ubuntu_package_sources_list %} {% block base_ubuntu_package_sources_list %}
@ -365,7 +366,8 @@ RUN apt-get update \
{%- for package in base_apt_packages | customizable('apt_packages') %} {%- for package in base_apt_packages | customizable('apt_packages') %}
{{ package }} \ {{ package }} \
{%- endfor %} {%- endfor %}
&& apt-get clean && apt-get clean \
&& rm -rf /var/lib/apt/lists/*
{% endblock %} {% endblock %}
{% if base_distro == 'ubuntu' %} {% if base_distro == 'ubuntu' %}

View File

@ -31,11 +31,16 @@ RUN sed -e "s/.*mariadb.*//Ig" -i /etc/apt/sources.list && apt-get purge -y mari
{% endif %} {% endif %}
{% block bifrost_ansible_install %} {% block bifrost_ansible_install %}
RUN bash -c './scripts/env-setup.sh && source ./env-vars && \ {% if base_distro in ['debian', 'ubuntu'] %}
RUN apt-get update && \
{% else %}
RUN echo " " && \
{% endif %}
bash -c './scripts/env-setup.sh && source ./env-vars && \
ansible-playbook -vvvv -i /bifrost/playbooks/inventory/target /bifrost/playbooks/install.yaml \ ansible-playbook -vvvv -i /bifrost/playbooks/inventory/target /bifrost/playbooks/install.yaml \
-e @/tmp/build_arg.yml && \ -e @/tmp/build_arg.yml && \
{% if base_distro in ['debian', 'ubuntu'] %} {% if base_distro in ['debian', 'ubuntu'] %}
apt-get clean' apt-get clean && rm -rf /var/lib/apt/lists/*'
{% else %} {% else %}
yum clean all' yum clean all'
{% endif %} {% endif %}

View File

@ -49,10 +49,12 @@ RUN usermod --append --home {{ homedir }} --groups kolla {{ name }} \
{% macro debian_haproxy_existing_user_fix() %} {% macro debian_haproxy_existing_user_fix() %}
{# NOTE(SamYaple): The postinst script breaks if the user 'haproxy' already exists #} {# NOTE(SamYaple): The postinst script breaks if the user 'haproxy' already exists #}
RUN apt-get -y install --no-install-recommends haproxy \ RUN apt-get update \
&& apt-get -y install --no-install-recommends haproxy \
|| sed -i '/^adduser/,+1 d' /var/lib/dpkg/info/haproxy.postinst \ || sed -i '/^adduser/,+1 d' /var/lib/dpkg/info/haproxy.postinst \
&& apt-get -y install -f \ && apt-get -y install -f \
&& apt-get clean && apt-get clean \
&& rm -rf /var/lib/apt/lists/*
{% endmacro %} {% endmacro %}
{% macro debian_opendaylight_existing_user_fix() %} {% macro debian_opendaylight_existing_user_fix() %}
@ -61,7 +63,8 @@ RUN apt-get update \
&& apt-get -y install --no-install-recommends opendaylight \ && apt-get -y install --no-install-recommends opendaylight \
|| sed -i '/^\s*adduser/,+1 d' /var/lib/dpkg/info/opendaylight.postinst \ || sed -i '/^\s*adduser/,+1 d' /var/lib/dpkg/info/opendaylight.postinst \
&& apt-get -y install -f \ && apt-get -y install -f \
&& apt-get clean && apt-get clean \
&& rm -rf /var/lib/apt/lists/*
{% endmacro %} {% endmacro %}
{% macro install_kubectl() %} {% macro install_kubectl() %}

View File

@ -49,6 +49,7 @@ def debian_package_install(packages):
' '.join(reg_packages) ' '.join(reg_packages)
)) ))
cmds.append('apt-get clean') cmds.append('apt-get clean')
cmds.append('rm -rf /var/lib/apt/lists/*')
# handle URL packages # handle URL packages
for url in url_packages: for url in url_packages: