ARG VERSION=dev
FROM jumpserver/gmssl:3.1.1-trixie AS gmssl-builder

FROM registry.fit2cloud.com/jumpserver/xpack:${VERSION} AS build-xpack
FROM jumpserver/core:${VERSION}-ce

COPY --from=build-xpack /opt/xpack /opt/jumpserver/apps/xpack

ARG TOOLS="                           \
        g++                           \
        iputils-ping                  \
        netcat-openbsd                \
        telnet"

RUN set -ex \
    && apt-get update \
    && apt-get -y install --no-install-recommends ${TOOLS} \
    && apt-get clean all \
    && rm -rf /var/lib/apt/lists/*

WORKDIR /opt/jumpserver

ARG PIP_MIRROR=https://pypi.org/simple

RUN set -ex \
    && uv pip install -i${PIP_MIRROR} --group xpack \
    && rm -rf /root/.cache/

COPY --from=gmssl-builder /usr/local/lib/libgmssl.so* /usr/local/lib/
COPY --from=gmssl-builder /usr/local/include/gmssl /usr/local/include/gmssl
COPY --from=gmssl-builder /usr/local/bin/gmssl /usr/local/bin/gmssl
