FROM registry.opensuse.org/opensuse/leap:15.3

#Enable all repose
RUN zypper mr -ea

# Refresh and update the repo
RUN zypper --gpg-auto-import-keys refresh
RUN zypper --gpg-auto-import-keys up -y

#Enable systemd
RUN zypper in -y dbus-1 systemd-sysvinit
RUN cp /usr/lib/systemd/system/dbus.service /etc/systemd/system/; \
    sed -i 's/OOMScoreAdjust=-900//' /etc/systemd/system/dbus.service

VOLUME ["/sys/fs/cgroup", "/run"]

RUN zypper in -y git-core
RUN git clone -b v3.2.2 https://github.com/cobbler/cobbler.git
RUN cd cobbler/

RUN mkdir /root/omnia

RUN zypper in --no-confirm python3-librepo \
                      python3-schema \
                      syslinux \
                      wget \
                      dhcp-server \
                      python3-pykickstart \
                      dnf-plugins-core \
                      cronie \
                      xinetd \
                      python3-coverage \
                      python3-Cheetah3 \
                      python3-netaddr \
                      python3-devel \
                      python3-future \
                      apache2-mod_wsgi-python3 \
                      gcc \
                      python-rpm-macros \
                      rpm-build \
                      ansible \
                      grub2-x86_64-efi \
                      shim \
                      yum-utils \
                      python3-Sphinx \
                      python3-wheel \
                      bash-completion \
                      tftp \
                      vim

RUN useradd -ms /bin/bash dhcpd

#Copy Configuration files
COPY settings.yaml /etc/cobbler/settings.yaml
COPY dhcp.template  /etc/cobbler/dhcp.template
COPY modules.conf  /etc/cobbler/modules.conf
COPY tftp /etc/xinetd.d/tftp
COPY .users.digest /etc/cobbler/users.digest
COPY cobbler_configurations_leap.yml /root
COPY tftp.yml /root
COPY inventory_creation.yml /root
COPY multi_cluster_provisioning.yml /root

EXPOSE 69 80 443 25151

VOLUME [ "/srv/www/cobbler", "/var/lib/cobbler/backup", "/mnt" ]

RUN systemctl enable apache2
RUN systemctl enable dhcpd

CMD ["sbin/init"]