# SPDX-License-Identifier: Apache-2.0

#!UseOBSRepositories
#!ExclusiveArch: aarch64 x86_64

# Unified BCI & Orchid Tags
#!BuildTag: containers/lmcache-lmstack-router:%%lmcache_lmstack_router_version%%%BUILD_FLAVOR%-%RELEASE%
#!BuildTag: containers/lmcache-lmstack-router:%%lmcache_lmstack_router_version%%%BUILD_FLAVOR%
#!BuildTag: containers/lmcache-lmstack-router:0%BUILD_FLAVOR%

#!ForceMultiVersion
#!BuildName: containers-lmcache-lmstack-router-0%BUILD_FLAVOR%
#!BuildVersion: %%lmcache_lmstack_router_version%%
#!BuildRelease: 0

FROM registry.suse.com/bci/bci-micro:15.6 AS micro
FROM registry.suse.com/bci/bci-base:15.6.47.5.6 AS base

# Install system packages using a container image that has zypper
FROM base AS builder
COPY --from=micro / /chroot/
ENV ZYPP_CONF=/scratch-zypp.conf
RUN printf '[main]\nrpm.install.excludedocs = yes\n' >/scratch-zypp.conf && \
    zypper --installroot /chroot -n --gpg-auto-import-keys in --no-recommends python311-vllm-router git && \
    zypper --installroot /chroot clean -a && \
    rm -rf /chroot/var/cache/zypp/* /chroot/var/log/zypp/*

FROM micro
# Copy all files to the final image
COPY --from=builder /chroot/ /

# Define labels according to https://en.suse.org/Building_derived_containers
# labelprefix=com.suse.application.lmcache-lmstack-router
LABEL org.opencontainers.image.authors=""
LABEL org.opencontainers.image.title="LMStack Router"
LABEL org.opencontainers.image.description="A lightweight, high-performance API router that directs requests to appropriate backends based on routing keys or session IDs to maximize KV cache reuse"
LABEL org.opencontainers.image.version="%%lmcache_lmstack_router_version%%"
LABEL org.opencontainers.image.url="https://apps.rancher.io/applications/vllm"
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="%%lmcache_lmstack_router_version%%%BUILD_FLAVOR%-%RELEASE%"
LABEL org.opencontainers.image.base.digest="%BASE_IMAGE_DIGEST%"
LABEL org.opencontainers.image.base.name="%BASE_IMAGE_TAG%"
LABEL org.opensuse.reference="dp.apps.rancher.io/containers/lmcache-lmstack-router:%%lmcache_lmstack_router_version%%-%RELEASE%"
LABEL org.openbuildservice.disturl="%DISTURL%"
LABEL com.suse.eula="sle-eula"
LABEL com.suse.lifecycle-url="https://www.suse.com/lifecycle"
LABEL com.suse.image-type="application"
LABEL com.suse.release-stage="released"
# endlabelprefix

ENV LANG en_US.UTF-8
ENV LC_ALL en_US.UTF-8

WORKDIR /app

ENTRYPOINT ["vllm-router"]
CMD []

