Skip to content

Commit 7bd304e

Browse files
committed
Update Docker tests for more compact/efficient images.
1 parent 62ed7cc commit 7bd304e

File tree

6 files changed

+72
-37
lines changed

6 files changed

+72
-37
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,4 @@ MIT / BSD
141141

142142
## Author Information
143143

144-
This role was created in 2014 by [Jeff Geerling](http://jeffgeerling.com/), author of [Ansible for DevOps](http://ansiblefordevops.com/).
144+
This role was created in 2014 by [Jeff Geerling](http://jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).

tests/Dockerfile.centos-6

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
FROM centos:6
2+
MAINTAINER Jeff Geerling
23

34
# Install Ansible
4-
RUN yum -y update; yum clean all;
5-
RUN yum -y install epel-release
6-
RUN yum -y install git ansible sudo
7-
RUN yum clean all
5+
RUN yum makecache fast \
6+
&& yum -y install deltarpm epel-release \
7+
&& yum -y update \
8+
&& yum -y install \
9+
ansible \
10+
sudo \
11+
&& yum clean all
812

913
# Disable requiretty
1014
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers

tests/Dockerfile.centos-7

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
FROM centos:7
2+
MAINTAINER Jeff Geerling
3+
ENV container=docker
24

35
# Install systemd -- See https://hub.docker.com/_/centos/
4-
RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs
5-
RUN yum -y update; yum clean all; \
6-
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
7-
rm -f /lib/systemd/system/multi-user.target.wants/*; \
8-
rm -f /etc/systemd/system/*.wants/*; \
6+
RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
7+
rm -f /lib/systemd/system/multi-user.target.wants/*;\
8+
rm -f /etc/systemd/system/*.wants/*;\
99
rm -f /lib/systemd/system/local-fs.target.wants/*; \
1010
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
1111
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
12-
rm -f /lib/systemd/system/basic.target.wants/*; \
12+
rm -f /lib/systemd/system/basic.target.wants/*;\
1313
rm -f /lib/systemd/system/anaconda.target.wants/*;
1414

15-
# Install Ansible
16-
RUN yum -y install epel-release
17-
RUN yum -y install git ansible sudo
18-
RUN yum clean all
15+
# Install Ansible and other requirements.
16+
RUN yum makecache fast \
17+
&& yum -y install deltarpm epel-release initscripts \
18+
&& yum -y update \
19+
&& yum -y install \
20+
ansible \
21+
sudo \
22+
&& yum clean all
1923

2024
# Disable requiretty
2125
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers

tests/Dockerfile.ubuntu-12.04

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
FROM ubuntu:12.04
2-
RUN apt-get update
2+
MAINTAINER Jeff Geerling
33

4-
# Install Ansible
5-
RUN apt-get install -y software-properties-common python-software-properties git
6-
RUN apt-add-repository -y ppa:ansible/ansible
7-
RUN apt-get update
8-
RUN apt-get install -y ansible
4+
ENV DEBIAN_FRONTEND noninteractive
95

10-
COPY initctl_faker .
11-
RUN chmod +x initctl_faker && rm -fr /sbin/initctl && ln -s /initctl_faker /sbin/initctl
6+
RUN apt-get update \
7+
&& apt-get install -y --no-install-recommends \
8+
software-properties-common \
9+
python-software-properties \
10+
&& rm -rf /var/lib/apt/lists/* \
11+
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
12+
&& apt-get clean
13+
# Install Ansible
14+
RUN apt-add-repository -y ppa:ansible/ansible \
15+
&& apt-get update \
16+
&& apt-get install -y --no-install-recommends \
17+
ansible \
18+
&& rm -rf /var/lib/apt/lists/* \
19+
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
20+
&& touch -m -t 200101010101.01 /var/lib/apt/periodic/update-success-stamp \
21+
&& apt-get clean
1222

1323
# Install Ansible inventory file
1424
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts

tests/Dockerfile.ubuntu-14.04

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
FROM ubuntu:14.04
2-
RUN apt-get update
2+
MAINTAINER Jeff Geerling
33

4-
# Install Ansible
5-
RUN apt-get install -y software-properties-common git
6-
RUN apt-add-repository -y ppa:ansible/ansible
7-
RUN apt-get update
8-
RUN apt-get install -y ansible
4+
ENV DEBIAN_FRONTEND noninteractive
95

10-
COPY initctl_faker .
11-
RUN chmod +x initctl_faker && rm -fr /sbin/initctl && ln -s /initctl_faker /sbin/initctl
6+
RUN apt-get update \
7+
&& apt-get install -y --no-install-recommends \
8+
software-properties-common \
9+
&& rm -Rf /var/lib/apt/lists/* \
10+
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
11+
&& apt-get clean
12+
# Install Ansible
13+
RUN apt-add-repository -y ppa:ansible/ansible \
14+
&& apt-get update \
15+
&& apt-get install -y --no-install-recommends \
16+
ansible \
17+
&& rm -rf /var/lib/apt/lists/* \
18+
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
19+
&& apt-get clean
1220

1321
# Install Ansible inventory file
1422
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts

tests/Dockerfile.ubuntu-16.04

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
FROM ubuntu:16.04
22

33
# Install dependencies.
4-
RUN apt-get update -qq -y
5-
RUN apt-get install -qq -y python-software-properties software-properties-common \
6-
rsyslog systemd systemd-cron sudo
4+
RUN apt-get update \
5+
&& apt-get install -y --no-install-recommends \
6+
python-software-properties \
7+
software-properties-common \
8+
rsyslog systemd systemd-cron sudo \
9+
&& rm -Rf /var/lib/apt/lists/* \
10+
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
11+
&& apt-get clean
712
RUN sed -i 's/^\($ModLoad imklog\)/#\1/' /etc/rsyslog.conf
813
#ADD etc/rsyslog.d/50-default.conf /etc/rsyslog.d/50-default.conf
914

1015
# Install Ansible
11-
RUN add-apt-repository -y ppa:ansible/ansible
12-
RUN apt-get update -y
13-
RUN apt-get install -y ansible git-core
16+
RUN add-apt-repository -y ppa:ansible/ansible \
17+
&& apt-get update
18+
&& apt-get install -y --no-install-recommends \
19+
ansible \
20+
&& rm -rf /var/lib/apt/lists/* \
21+
&& rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
22+
&& apt-get clean
1423

1524
COPY initctl_faker .
1625
RUN chmod +x initctl_faker && rm -fr /sbin/initctl && ln -s /initctl_faker /sbin/initctl

0 commit comments

Comments
 (0)