<gh_stars>1-10
FROM buluma/ubuntu:jammy

LABEL maintainer="<NAME>"

ARG DEBIAN_FRONTEND=noninteractive

ENV pip_packages "ansible"

# Install dependencies.
RUN apt-get update \
    # && apt-get install -y --no-install-recommends \
    && apt-get install -y \
       apt-utils \
       build-essential \
       locales \
       gnupg \
       bison \
       tcpdump \
       net-tools \
       screen \
       bash-completion \
       telnet \
       curl \
       debian-archive-keyring \
       openssh-server \
       ruby \
       libelf-dev \
       libffi-dev \
       libssl-dev \
       libyaml-dev \
       python3-dev \
       python3-setuptools \
       python3-pip \
       python3-yaml \
       software-properties-common \
       rsyslog systemd systemd-cron sudo iproute2 \
    && apt-get clean \
    && rm -Rf /var/lib/apt/lists/* \
    && rm -Rf /usr/share/doc && rm -Rf /usr/share/man

# hadolint ignore=DL3009
RUN sed -i 's/^\($ModLoad imklog\)/#\1/' /etc/rsyslog.conf

# Fix potential UTF-8 errors with ansible-test.
RUN locale-gen en_US.UTF-8

# Install Ansible via Pip. Avoid use of cache directory with pip.
RUN pip3 install --no-cache-dir $pip_packages

# hadolint ignore=DL3045
COPY initctl_faker .
RUN chmod +x initctl_faker && rm -fr /sbin/initctl && ln -s /initctl_faker /sbin/initctl

# Install Ansible inventory file.
RUN mkdir -p /etc/ansible
# hadolint ignore=ShellCheck-SC2028
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts

# Remove unnecessary getty and udev targets that result in high CPU usage when using
# multiple containers with Molecule (https://github.com/ansible/molecule/issues/1104)
RUN rm -f /lib/systemd/system/systemd*udev* \
  && rm -f /lib/systemd/system/getty.target

VOLUME ["/sys/fs/cgroup", "/tmp", "/run"]
CMD ["/lib/systemd/systemd"]
