# Riversoft STCP Gemini and Riversoft STCP DirectLink test environment.
# One base image with the Riversoft repository and one target per service.
# For testing only: do not use these images in production.

ARG OL_VERSION=9

FROM oraclelinux:${OL_VERSION} AS base
ARG OL_VERSION
RUN curl -fsSL https://repo.riversoft.com.br/configs/riversoft-el${OL_VERSION}.repo \
      --output /etc/yum.repos.d/riversoft-release.repo \
 && dnf -y install jq procps-ng \
 && dnf clean all && rm -rf /var/cache/dnf
COPY entrypoints/common.sh /opt/riversoft/common.sh

# Riversoft STCP Gemini API + Riversoft Console Portal (served by the API with -lite)
FROM base AS stcpgemini-api
RUN dnf -y install stcpgemini-api stcpgemini-portal \
 && dnf clean all && rm -rf /var/cache/dnf
COPY entrypoints/stcpgemini-api.sh /opt/riversoft/entrypoint.sh
EXPOSE 33070
ENTRYPOINT ["/bin/bash", "/opt/riversoft/entrypoint.sh"]

# Riversoft STCP Gemini Server + Riversoft STCP Gemini Rename (same image, as the documentation requires)
FROM base AS stcpgemini-server
RUN dnf -y install stcpgemini-server stcpren \
 && cp /usr/local/stcp/configs/example-stcplibs-x86_64.ld.so.conf /etc/ld.so.conf.d/stcplibs.conf \
 && ldconfig \
 && dnf clean all && rm -rf /var/cache/dnf
COPY entrypoints/stcpren.sh /opt/riversoft/stcpren.sh
COPY entrypoints/stcpgemini-server.sh /opt/riversoft/entrypoint.sh
ENTRYPOINT ["/bin/bash", "/opt/riversoft/entrypoint.sh"]

# Riversoft STCP DirectLink + Riversoft STCP DirectLink Portal + Riversoft STCP Gemini Rename
FROM base AS stcpdirectlink
ARG STCPDIRECTLINK_PORTAL_VERSION=3.12.1-0
RUN dnf -y install stcpdirectlink stcpdirectlink-portal-${STCPDIRECTLINK_PORTAL_VERSION} stcpren \
 && dnf clean all && rm -rf /var/cache/dnf
COPY entrypoints/stcpren.sh /opt/riversoft/stcpren.sh
COPY entrypoints/stcpdirectlink.sh /opt/riversoft/entrypoint.sh
ENTRYPOINT ["/bin/bash", "/opt/riversoft/entrypoint.sh"]
