FROM docker.io/library/archlinux:latest

RUN pacman --sync --sysupgrade --refresh --noconfirm && \
    pacman --sync --noconfirm \
      ansible \
      ansible-lint \
      base-devel \
      libffi \
      openssl \
      libyaml \
      python \
      python-setuptools \
      python-pip \
      python-pytest \
      python-yaml \
      sshpass \
      systemd \
      sudo \
      iproute2 && \
    rm --recursive --force /usr/share/doc && \
    rm --recursive --force /usr/share/man && \
    rm --recursive --force /var/cache/pacman/pkg

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

# COPY initctl_faker .
# RUN chmod +x initctl_faker && \
#     rm --recursive --force /sbin/initctl && \
#     ln --symbolic /initctl_faker /sbin/initctl

# Install Ansible inventory file
RUN mkdir --parents /etc/ansible
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 --recursive --force /lib/systemd/system/systemd*udev* && \
    rm --recursive --force /lib/systemd/system/getty.target

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