FROM bellsoft/liberica-openjdk-rocky:21.0.12-cds@sha256:b8493dbedf98eb152731f75ef52b9e6cd2fecc0f54684d5a5d7abd7703139490

ARG SEATUNNEL_VERSION=2.3.13
ENV SEATUNNEL_HOME=/opt/seatunnel \
    JAVA_HOME=/usr/lib/jvm/jdk-21.0.12.1-bellsoft-x86_64

COPY local/artifacts/apache-seatunnel-2.3.13-bin.tar.gz /tmp/apache-seatunnel-2.3.13-bin.tar.gz
RUN microdnf -y install curl procps-ng shadow-utils && \
    microdnf clean all && \
    tar -xzf /tmp/apache-seatunnel-2.3.13-bin.tar.gz -C /opt && \
    mv "/opt/apache-seatunnel-${SEATUNNEL_VERSION}" "$SEATUNNEL_HOME" && \
    rm -f /tmp/apache-seatunnel-2.3.13-bin.tar.gz && \
    (id seatunnel >/dev/null 2>&1 || useradd --no-create-home --shell /sbin/nologin --uid 1001 seatunnel) && \
    install -d -o seatunnel -g seatunnel /opt/aixun-poc /tmp/seatunnel && \
    chown -R seatunnel:seatunnel "$SEATUNNEL_HOME"

COPY --chmod=0555 start-seatunnel.sh /opt/aixun-poc/start-seatunnel.sh
USER seatunnel
WORKDIR /opt/seatunnel
ENTRYPOINT ["/opt/aixun-poc/start-seatunnel.sh"]
