#!BuildTag: suse/manager/4.3/proxy-squid:latest suse/manager/4.3/proxy-squid:4.3.0-public-rc suse/manager/4.3/proxy-squid:4.3.0-public-rc.%RELEASE%

ARG BASE=registry.suse.com/bci/bci-base:15.3
FROM $BASE

ARG PRODUCT_REPO
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"

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

# Build Service required labels
# labelprefix=com.suse.manager.proxy-squid
LABEL org.opencontainers.image.title="${PRODUCT} proxy squid container"
LABEL org.opencontainers.image.description="Image contains a ${PRODUCT} proxy component cache http requests"
LABEL org.opencontainers.image.created="%BUILDTIME%"
LABEL org.opencontainers.image.vendor="${VENDOR}"
LABEL org.opencontainers.image.url="${URL}"
LABEL org.opencontainers.image.version="4.3.0-public-rc"
LABEL org.openbuildservice.disturl="%DISTURL%"
LABEL org.opensuse.reference="${REFERENCE_PREFIX}/proxy-squid:4.3.0-public-rc.%RELEASE%"
# endlabelprefix

# Squid
EXPOSE 8080/tcp

VOLUME [ "/etc/uyuni", "/var/cache/squid" ]

RUN zypper --gpg-auto-import-keys --non-interactive install --auto-agree-with-licenses python3 python3-PyYAML
RUN zypper --gpg-auto-import-keys --non-interactive install --auto-agree-with-licenses squid

COPY squid.conf /etc/squid/squid.conf

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

CMD uyuni-configure.py && squid -z --foreground && squid -FC -d 1 --foreground
