#!ExclusiveArch: x86_64
# Define the names/tags of the container
#!BuildTag: bci/dotnet-sdk:5.0
#!BuildTag: bci/dotnet-sdk:5.0-%RELEASE%
#!BuildTag: bci/dotnet-sdk:5.0.13
#!BuildTag: bci/dotnet-sdk:5.0.13-%RELEASE%
FROM suse/sle15:15.3

# telemetry opt out: https://docs.microsoft.com/en-us/dotnet/core/tools/telemetry#how-to-opt-out
ENV DOTNET_CLI_TELEMETRY_OPTOUT=1

# Define labels according to https://en.opensuse.org/Building_derived_containers
# labelprefix=com.suse.bci.dotnet.sdk
PREFIXEDLABEL org.opencontainers.image.title="SLE BCI .Net 5.0 SDK Container Image"
PREFIXEDLABEL org.opencontainers.image.description="Image containing the .Net 5.0 SDK based on the SLE Base Container Image."
PREFIXEDLABEL org.opencontainers.image.version="5.0"
PREFIXEDLABEL org.opencontainers.image.url="https://www.suse.com/products/server/"
PREFIXEDLABEL org.opencontainers.image.created="%BUILDTIME%"
PREFIXEDLABEL org.opencontainers.image.vendor="SUSE LLC"
PREFIXEDLABEL org.opensuse.reference="registry.suse.com/bci/dotnet-sdk:5.0"
PREFIXEDLABEL org.openbuildservice.disturl="%DISTURL%"
PREFIXEDLABEL com.suse.techpreview="true"
PREFIXEDLABEL com.suse.image-type="sle-bci"
PREFIXEDLABEL com.suse.eula="sle-bci"
PREFIXEDLABEL com.suse.release-stage="released"
PREFIXEDLABEL com.suse.lifecycle-url="https://www.suse.com/lifecycle/"
# endlabelprefix

# The MS GPG keys
COPY microsoft.asc /tmp

COPY aspnetcore-runtime-5.0.13-x64.rpm /tmp
COPY aspnetcore-targeting-pack-5.0.0.rpm /tmp
COPY dotnet-apphost-pack-5.0.13-x64.rpm /tmp
COPY dotnet-host-5.0.13-x64.rpm /tmp
COPY dotnet-hostfxr-5.0.13-x64.rpm /tmp
COPY dotnet-runtime-5.0.13-x64.rpm /tmp
COPY dotnet-runtime-deps-5.0.13-sles.12-x64.rpm /tmp
COPY dotnet-sdk-5.0.404-x64.rpm /tmp
COPY dotnet-targeting-pack-5.0.0-x64.rpm /tmp
COPY netstandard-targeting-pack-2.1.0-x64.rpm /tmp

COPY prod.repo /tmp

# Workaround for https://github.com/openSUSE/obs-build/issues/487
RUN zypper --non-interactive install --no-recommends sles-release

# Importing MS GPG keys
RUN rpm --import /tmp/microsoft.asc

# Use the package for ICU offered by SLES
RUN zypper --non-interactive install --no-recommends libicu vim


RUN zypper --non-interactive install --no-recommends \ 
        /tmp/aspnetcore-runtime-5.0.13-x64.rpm \ 
        /tmp/aspnetcore-targeting-pack-5.0.0.rpm \ 
        /tmp/dotnet-apphost-pack-5.0.13-x64.rpm \ 
        /tmp/dotnet-host-5.0.13-x64.rpm \ 
        /tmp/dotnet-hostfxr-5.0.13-x64.rpm \ 
        /tmp/dotnet-runtime-5.0.13-x64.rpm \ 
        /tmp/dotnet-runtime-deps-5.0.13-sles.12-x64.rpm \ 
        /tmp/dotnet-sdk-5.0.404-x64.rpm \ 
        /tmp/dotnet-targeting-pack-5.0.0-x64.rpm \ 
        /tmp/netstandard-targeting-pack-2.1.0-x64.rpm

RUN cp /tmp/prod.repo /etc/zypp/repos.d/microsoft-dotnet-prod.repo

RUN zypper -n addlock dotnet-host

RUN rm -rf /tmp/* && zypper clean && rm -rf /var/log/*