# SPDX-License-Identifier: MIT
#!BuildTag: suse/manager/4.3/proxy-salt-broker:latest suse/manager/4.3/proxy-salt-broker:4.3.17 suse/manager/4.3/proxy-salt-broker:4.3.17.%RELEASE%

ARG BASE=registry.suse.com/suse/ltss/sle15.4/sle15:15.4
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 && zypper clean --all

# Additional material
COPY uyuni-configure.py /usr/bin/uyuni-configure.py
RUN chmod +x /usr/bin/uyuni-configure.py

# Prepare for slimming down
COPY prepare_target.sh .
RUN sh prepare_target.sh

# Define slim image
ARG BASE=registry.suse.com/bci/bci-base:15.4
FROM $BASE AS slim

ARG PRODUCT="SUSE Manager"
ARG VENDOR="SUSE LLC"
ARG URL="https://www.suse.com/products/suse-manager/"
ARG REFERENCE_PREFIX="registry.suse.com/suse/manager/4.3"
ARG PRODUCT_VERSION="4.3.17"

RUN zypper --gpg-auto-import-keys --non-interactive install --auto-agree-with-licenses python3 python3-PyYAML python3-pyzmq && zypper clean --all
COPY --from=fat /target /

# Build Service required labels
# labelprefix=com.suse.manager.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=4.3.21
LABEL org.openbuildservice.disturl="%DISTURL%"
LABEL org.opensuse.reference="${REFERENCE_PREFIX}/proxy-salt-broker:4.3.17.%RELEASE%"
# endlabelprefix
LABEL org.uyuni.version="${PRODUCT_VERSION}"

# Salt
EXPOSE 4505/tcp
EXPOSE 4506/tcp

VOLUME "/etc/uyuni"

CMD uyuni-configure.py && salt-broker
