# SPDX-License-Identifier: MIT
#!BuildTag: suse/multi-linux-manager/5.1/%ARCH%/proxy-salt-broker:5.1.2 suse/multi-linux-manager/5.1/%ARCH%/proxy-salt-broker:5.1.2.%RELEASE% suse/multi-linux-manager/5.1/%ARCH%/proxy-salt-broker:latest

ARG BASE=registry.suse.com/bci/bci-base:15.6
FROM $BASE AS fat

ARG PRODUCT_REPO

# Add distro and product repos
COPY add_repos.sh /usr/bin
RUN sh add_repos.sh ${PRODUCT_REPO}

# Main packages
RUN zypper --gpg-auto-import-keys --non-interactive install --auto-agree-with-licenses \
        spacewalk-proxy-salt \
        python3 \
        python3-PyYAML \
        python3-pyzmq && \
    zypper --non-interactive clean --all && \
    rpm -e container-suseconnect && \
    rm -rf /var/log/{alternatives.log,lastlog,tallylog,suseconnect.log,zypper.log,zypp/history,YaST2}

# Additional material
COPY --chmod=555 uyuni-configure.py /usr/bin/uyuni-configure.py

ARG PRODUCT="SUSE Multi-Linux Manager"
ARG VENDOR="SUSE LLC"
ARG URL="https://www.uyuni-project.org/"
ARG REFERENCE_PREFIX="registry.opensuse.org/uyuni"
ARG PRODUCT_VERSION="5.1.2"

# Build Service required labels
# labelprefix=com.suse.multilinuxmanager.proxy-salt-broker
LABEL com.suse.supportlevel="l3"
LABEL com.suse.lifecycle-url="https://www.suse.com/lifecycle/"
LABEL com.suse.release-stage="released"
LABEL com.suse.eula="sle-eula"
LABEL org.opencontainers.image.title="${PROJECT} proxy salt-broker container"
LABEL org.opencontainers.image.description="Image contains a ${PRODUCT} proxy component to forward Salt connections"
LABEL org.opencontainers.image.created="%BUILDTIME%"
LABEL org.opencontainers.image.vendor="${VENDOR}"
LABEL org.opencontainers.image.url="${URL}"
LABEL org.opencontainers.image.name=proxy-salt-broker-image
LABEL org.opencontainers.image.version=5.1.12
LABEL org.openbuildservice.disturl="%DISTURL%"
LABEL org.opensuse.reference="${REFERENCE_PREFIX}/%ARCH%/proxy-salt-broker:5.1.2.%RELEASE%"
# endlabelprefix
LABEL org.uyuni.version="${PRODUCT_VERSION}"

# Salt
EXPOSE 4505/tcp
EXPOSE 4506/tcp

VOLUME "/etc/uyuni"

CMD uyuni-configure.py && salt-broker
