From cabbafb65036bc62417586eeee8b83faad7fe268 Mon Sep 17 00:00:00 2001 From: Matt Clay Date: Tue, 14 Jun 2016 16:15:32 -0700 Subject: [PATCH] Update Fedora and CentOS docker images. - Reduce image size by skipping weak package references. - Consolidate and sort packages to install. - Improve consistency between versions. - Combine yum/dnf install and clean to avoid unwanted caching. - Don't update existing packages from base image unnecessarily. --- test/utils/docker/centos6/Dockerfile | 41 +++++++++++---------- test/utils/docker/centos7/Dockerfile | 34 +++++++++-------- test/utils/docker/fedora-rawhide/Dockerfile | 24 +++++++----- test/utils/docker/fedora23/Dockerfile | 33 ++++++++++------- 4 files changed, 74 insertions(+), 58 deletions(-) diff --git a/test/utils/docker/centos6/Dockerfile b/test/utils/docker/centos6/Dockerfile index 3f624d2d7fd..bbcee65b043 100644 --- a/test/utils/docker/centos6/Dockerfile +++ b/test/utils/docker/centos6/Dockerfile @@ -1,48 +1,49 @@ -# Latest version of centos FROM centos:centos6 -RUN yum -y update; yum clean all; -RUN yum -y install \ + +RUN yum clean all && \ + yum -y install epel-release && \ + yum -y install \ acl \ asciidoc \ bzip2 \ - epel-release \ file \ gcc \ git \ make \ mercurial \ mysql \ - mysql-server \ MySQL-python \ - rpm-build \ - rubygems \ - sed \ - subversion \ - sudo \ - unzip \ + mysql-server \ openssh-clients \ openssh-server \ - which \ - zip -RUN yum -y install \ - PyYAML \ python-coverage \ python-devel \ python-httplib2 \ - python-jinja2 \ python-keyczar \ python-mock \ python-nose \ python-paramiko \ python-pip \ python-setuptools \ - python-virtualenv -RUN pip install --upgrade jinja2 -RUN rpm -e --nodeps python-crypto; pip install pycrypto + python-virtualenv \ + PyYAML \ + rpm-build \ + rubygems \ + sed \ + subversion \ + sudo \ + unzip \ + which \ + zip \ + && \ + yum clean all + +RUN rpm -e --nodeps python-crypto && pip install --upgrade jinja2 pycrypto + RUN /bin/sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers RUN mkdir /etc/ansible/ RUN /bin/echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts -#VOLUME /sys/fs/cgroup /run /tmp +VOLUME /sys/fs/cgroup /run /tmp RUN ssh-keygen -q -t rsa1 -N '' -f /etc/ssh/ssh_host_key && \ ssh-keygen -q -t dsa -N '' -f /etc/ssh/ssh_host_dsa_key && \ ssh-keygen -q -t rsa -N '' -f /etc/ssh/ssh_host_rsa_key && \ diff --git a/test/utils/docker/centos7/Dockerfile b/test/utils/docker/centos7/Dockerfile index d61a6cd46a1..eb84c66c923 100644 --- a/test/utils/docker/centos7/Dockerfile +++ b/test/utils/docker/centos7/Dockerfile @@ -1,6 +1,5 @@ -# Latest version of centos FROM centos:centos7 -RUN yum -y update; yum clean all; yum -y swap fakesystemd systemd + RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ rm -f /lib/systemd/system/multi-user.target.wants/*; \ rm -f /etc/systemd/system/*.wants/*; \ @@ -9,29 +8,23 @@ rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ rm -f /lib/systemd/system/basic.target.wants/*; \ rm -f /lib/systemd/system/anaconda.target.wants/*; -RUN yum -y install \ + +RUN yum clean all && \ + yum -y install epel-release && \ + yum -y install \ acl \ asciidoc \ - dbus-python \ bzip2 \ - epel-release \ + dbus-python \ file \ git \ iproute \ make \ - mercurial \ mariadb-server \ + mercurial \ MySQL-python \ - rpm-build \ - rubygems \ - subversion \ - sudo \ - unzip \ openssh-clients \ openssh-server \ - which -RUN yum -y install \ - PyYAML \ python-coverage \ python-httplib2 \ python-jinja2 \ @@ -41,7 +34,18 @@ RUN yum -y install \ python-paramiko \ python-pip \ python-setuptools \ - python-virtualenv + python-virtualenv \ + PyYAML \ + rpm-build \ + rubygems \ + subversion \ + sudo \ + unzip \ + which \ + && \ + yum -y swap fakesystemd systemd && \ + yum clean all + RUN /usr/bin/sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers RUN mkdir /etc/ansible/ RUN /usr/bin/echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts diff --git a/test/utils/docker/fedora-rawhide/Dockerfile b/test/utils/docker/fedora-rawhide/Dockerfile index 8e5fd624afd..b838bdf9459 100644 --- a/test/utils/docker/fedora-rawhide/Dockerfile +++ b/test/utils/docker/fedora-rawhide/Dockerfile @@ -1,6 +1,5 @@ -# Latest version of fedora rawhide FROM fedora:rawhide -RUN dnf -y update; dnf clean all + RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ rm -f /lib/systemd/system/multi-user.target.wants/*; \ rm -f /etc/systemd/system/*.wants/*; \ @@ -9,24 +8,27 @@ rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ rm -f /lib/systemd/system/basic.target.wants/*; \ rm -f /lib/systemd/system/anaconda.target.wants/*; -RUN dnf -y install \ + +RUN dnf clean all && \ + dnf -y --setopt=install_weak_deps=false install \ acl \ asciidoc \ - dbus-python \ bzip2 \ + dbus-python \ file \ findutils \ git \ glibc-locale-source \ iproute \ make \ - mercurial \ mariadb-server \ + mercurial \ MySQL-python \ + openssh-clients \ + openssh-server \ procps \ - PyYAML \ - python-coverage \ python2-dnf \ + python-coverage \ python-httplib2 \ python-jinja2 \ python-keyczar \ @@ -36,6 +38,7 @@ RUN dnf -y install \ python-pip \ python-setuptools \ python-virtualenv \ + PyYAML \ rpm-build \ rubygems \ subversion \ @@ -43,10 +46,11 @@ RUN dnf -y install \ tar \ unzip \ which \ - openssh-clients \ - openssh-server \ yum \ - zip + zip \ + && \ + dnf clean all + RUN localedef --quiet -c -i en_US -f UTF-8 en_US.UTF-8 RUN /usr/bin/sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers RUN mkdir /etc/ansible/ diff --git a/test/utils/docker/fedora23/Dockerfile b/test/utils/docker/fedora23/Dockerfile index 9d1ebf0b551..4058a1a13f4 100644 --- a/test/utils/docker/fedora23/Dockerfile +++ b/test/utils/docker/fedora23/Dockerfile @@ -1,6 +1,5 @@ -# Latest version of fedora 23 FROM fedora:23 -RUN dnf -y update; dnf clean all + RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ rm -f /lib/systemd/system/multi-user.target.wants/*; \ rm -f /etc/systemd/system/*.wants/*; \ @@ -9,24 +8,26 @@ rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ rm -f /lib/systemd/system/basic.target.wants/*; \ rm -f /lib/systemd/system/anaconda.target.wants/*; -RUN dnf -y install \ + +RUN dnf clean all && \ + dnf -y --setopt=install_weak_deps=false install \ acl \ asciidoc \ - dbus-python \ bzip2 \ + dbus-python \ file \ findutils \ - glibc-common \ git \ iproute \ make \ - mercurial \ mariadb-server \ + mercurial \ MySQL-python \ + openssh-clients \ + openssh-server \ procps \ - PyYAML \ - python-coverage \ python2-dnf \ + python-coverage \ python-httplib2 \ python-jinja2 \ python-keyczar \ @@ -36,6 +37,7 @@ RUN dnf -y install \ python-pip \ python-setuptools \ python-virtualenv \ + PyYAML \ rpm-build \ rubygems \ subversion \ @@ -43,12 +45,17 @@ RUN dnf -y install \ tar \ unzip \ which \ - openssh-clients \ - openssh-server \ yum \ - zip -RUN localedef --quiet -f ISO-8859-1 -i pt_BR pt_BR -RUN localedef --quiet -f ISO-8859-1 -i es_MX es_MX + zip \ + && \ + dnf clean all + +RUN dnf -y --setopt=install_weak_deps=false update glibc-common && \ + localedef --quiet -f ISO-8859-1 -i pt_BR pt_BR && \ + localedef --quiet -f ISO-8859-1 -i es_MX es_MX && \ + dnf clean all + +RUN localedef --quiet -c -i en_US -f UTF-8 en_US.UTF-8 RUN /usr/bin/sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers RUN mkdir /etc/ansible/ RUN /usr/bin/echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts