Debian Codegraph @

ansible_collections/google/cloud/molecule/gcsfuse/Dockerfile.j2

raw
1 # Molecule managed
2
3 {% if item.registry is defined %}
4 FROM {{ item.registry.url }}/{{ item.image }}
5 {% else %}
6 FROM {{ item.image }}
7 {% endif %}
8 ENV container=docker
9
10 {# Initial Package Installs and Container Prep #}
11 {% if item.image.split(':', 1)[0] in ["ubuntu"] %}
12 RUN apt-get update \
13 && apt-get install -y --no-install-recommends \
14 locales software-properties-common rsyslog systemd systemd-cron sudo \
15 iproute2
16 RUN sed -i 's/^\($ModLoad imklog\)/#\1/' /etc/rsyslog.conf
17 {% elif item.image.split(':', 1)[0] in ["debian"] %}
18 RUN apt-get update \
19 && apt-get install -y --no-install-recommends \
20 sudo systemd systemd-sysv \
21 build-essential wget
22 {% elif item.image.split(':', 1)[0] in ["centos"] %}
23 {% if item.image in ["centos:7"] %}
24 RUN yum makecache fast && yum -y install deltarpm \
25 {% elif item.image in ["centos:8"] %}
26 RUN yum makecache --timer \
27 {% endif %}
28 && yum -y install epel-release \
29 && yum -y update \
30 && yum -y install sudo which
31 {% endif %}
32
33
34 {# Install of Python2 #}
35 {% if item.image in ["ubuntu:16.04"] %}
36 RUN apt-get update \
37 && apt-get install -y --no-install-recommends python-setuptools wget \
38 && wget https://bootstrap.pypa.io/get-pip.py \
39 && python get-pip.py
40 {% elif item.image in ["debian:9"] %}
41 RUN apt-get update \
42 && apt-get install -y --no-install-recommends libffi-dev libssl-dev \
43 python-pip python-dev python-setuptools python-wheel
44 {% elif item.image in ["centos:7"] %}
45 RUN yum -y install python-pip
46 {% endif %}
47
48 {# Install of Python3 #}
49 {% if item.image in ["ubuntu:18.04", "ubuntu:20.04", "ubuntu:24.04", "debian:10", "debian:11", "debian:12"] %}
50 RUN apt-get update \
51 && apt-get install -y --no-install-recommends \
52 apt-utils python3-setuptools python3-pip
53 {% endif %}
54 {% if item.image in ["centos:8"] %}
55 RUN yum -y install hostname python3 python3-pip
56 {% endif %}
57
58 {# Steps for cleanup #}
59 {% if item.image.split(':', 1)[0] in ["ubuntu", "debian"] %}
60 RUN rm -Rf /var/lib/apt/lists/* \
61 && rm -Rf /usr/share/doc && rm -Rf /usr/share/man \
62 && apt-get clean
63 {% elif item.image.split(':', 1)[0] in ["centos"] %}
64 RUN yum clean all
65 {% endif %}
66
67 {# Steps for clenaup of systemd #}
68 {% if item.image in ["centos:7", "centos:8", "debian:9"] %}
69 RUN (cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == \
70 systemd-tmpfiles-setup.service ] || rm -f $i; done); \
71 rm -f /lib/systemd/system/multi-user.target.wants/*;\
72 rm -f /etc/systemd/system/*.wants/*;\
73 rm -f /lib/systemd/system/local-fs.target.wants/*; \
74 rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
75 rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
76 rm -f /lib/systemd/system/basic.target.wants/*;\
77 rm -f /lib/systemd/system/anaconda.target.wants/*; \
78 mkdir -p /run/systemd/system
79 {% endif %}
80 {% if item.image in ["ubuntu:18.04", "ubuntu:20.04"] %}
81 # Remove unnecessary getty and udev targets that result in high CPU usage when using
82 # multiple containers with Molecule (https://github.com/ansible/molecule/issues/1104)
83 RUN rm -f /lib/systemd/system/systemd*udev* \
84 && rm -f /lib/systemd/system/getty.target
85 {% endif %}
86
87
88 {% if item.image in ["centos:7", "centos:8"] %}
89 # Disable requiretty.
90 RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers
91 {% endif %}
92
93 {% if item.image.split(':', 1)[0] not in ["centos", "debian"] %}
94 # Fix potential UTF-8 errors with ansible-test.
95 RUN locale-gen en_US.UTF-8
96 {% endif %}
97
98 # Install Ansible inventory file.
99 RUN mkdir -p /etc/ansible
100 RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
101
102 {% if item.image in ["centos:7", "centos:8", "debian:9", "debian:10", "debian:11", "debian:12"] %}
103 VOLUME ["/sys/fs/cgroup"]
104 {% elif item.image in ["ubuntu:16.04", "ubuntu:18.04", "ubuntu:20.04", "ubuntu:24.04"] %}
105 VOLUME ["/sys/fs/cgroup", "/tmp", "/run"]
106 {% endif %}
107 {% if item.image in ["centos:7", "centos:8"] %}
108 CMD ["/usr/sbin/init"]
109 {% elif item.image in ["ubuntu:16.04", "ubuntu:18.04", "ubuntu:20.04", "ubuntu:24.04", "debian:9", "debian:10", "debian:11", "debian:12"] %}
110 CMD ["/lib/systemd/systemd"]
111 {% endif %}