# Copyright 2025-2026 SUSE LLC
# SPDX-License-Identifier: Apache-2.0

# Note: This file should be the same as the one in the root of the repository
# Ref: https://openbuildservice.org/help/manuals/obs-user-guide/cha-obs-supported-formats
# Ref: https://github.com/bmwiedemann/openSUSE/tree/master/packages/o/obs-service-kiwi_metainfo_helper
# Ref: https://github.com/bmwiedemann/openSUSE/tree/master/packages/o/obs-service-docker_label_helper

#!BuildTag: trento/mcp-server-trento:latest
#!BuildTag: trento/mcp-server-trento:%%VERSION%%
#!BuildTag: trento/mcp-server-trento:%%VERSION%%-build%RELEASE%

#!BuildName: mcp-server-trento
#!BuildVersion: %%VERSION%%

#!UseOBSRepositories
#!ExclusiveArch: x86_64

FROM registry.suse.com/bci/bci-base:15.7

# See https://github.com/SUSE/BCI-dockerfile-generator for more details on how this file is generated and used.

RUN set -euo pipefail; \
    zypper -n install --no-recommends mcp-server-trento

# cleanup logs and temporary files
RUN set -euo pipefail; zypper -n clean -a; \
    rm -rf {/target,}/var/log/{alternatives.log,lastlog,tallylog,zypper.log,zypp/history,YaST2}; \
    rm -rf {/target,}/run/*; \
    rm -f {/target,}/etc/{shadow-,group-,passwd-,.pwd.lock}; \
    rm -f {/target,}/usr/lib/sysimage/rpm/.rpm.lock; \
    rm -f {/target,}/var/lib/zypp/AnonymousUniqueId; \
    rm -f {/target,}/var/lib/zypp/AutoInstalled; \
    rm -f {/target,}/var/cache/ldconfig/aux-cache

# set the day of last password change to empty
RUN set -euo pipefail; sed -i 's/^\([^:]*:[^:]*:\)[^:]*\(:.*\)$/\1\2/' /etc/shadow

# Define labels according to https://en.opensuse.org/Building_derived_containers
# labelprefix=com.suse.trento
LABEL org.opencontainers.image.authors="https://github.com/trento-project/mcp-server/graphs/contributors"
LABEL org.opencontainers.image.title="Trento MCP Server"
LABEL org.opencontainers.image.description="Model Context Protocol server wrapping Trento API"
LABEL org.opencontainers.image.documentation="https://documentation.suse.com/sles-sap/trento"
LABEL org.opencontainers.image.version="%%VERSION%%"
LABEL org.opencontainers.image.url="https://github.com/trento-project/mcp-server"
LABEL org.opencontainers.image.created="%BUILDTIME%"
LABEL org.opencontainers.image.vendor="SUSE LLC"
LABEL org.opencontainers.image.source="%SOURCEURL%"
LABEL org.opencontainers.image.ref.name="%%VERSION%%-build%RELEASE%"
LABEL org.opensuse.reference="registry.suse.com/trento/mcp-server-trento:%%VERSION%%-build%RELEASE%"
LABEL org.openbuildservice.disturl="%DISTURL%"
LABEL com.suse.supportlevel="l3"
LABEL com.suse.supportlevel.until=""
LABEL com.suse.eula="sle-eula"
LABEL com.suse.lifecycle-url="https://www.suse.com/lifecycle#suse-linux-enterprise-server-for-sap-applications-15"
LABEL com.suse.release-stage="released"
# endlabelprefix
LABEL org.opencontainers.image.base.name="%BASE_REFNAME%"
LABEL org.opencontainers.image.base.digest="%BASE_DIGEST%"
LABEL io.artifacthub.package.logo-url="https://www.trento-project.io/images/trento-icon.svg"
LABEL io.artifacthub.package.readme-url="%SOURCEURL_WITH(README.md)%"

USER 1001

EXPOSE 5000/tcp

ENTRYPOINT [ "/usr/bin/mcp-server-trento" ]
