FROM alpine/java:21-jre

LABEL maintainer="ODOO4projects" \
      application="VSCU" \
      version="1.0.3"

WORKDIR /app

COPY vscu/vscu.jar vscu.jar

COPY vscu/config/vscu.properties config/vscu.properties

RUN mkdir -p /app/data
VOLUME ["/app/data"]

EXPOSE 8088

ENV JAVA_OPTS="-Xms512m -Xmx4096m -XX:-LoopUnswitching"

ENV VSCU_PORT=8088 \
    VSCU_PROFILE=sbx \
    VSCU_WORKING_DIR=/app/data \
    VSCU_NO_SCH_THREADS=3 \
    VSCU_BATCH_SIZE=30 \
    VSCU_EXEC_MODE=OFFLINE \
    VSCU_LOGGING_LEVEL=INFO \
    VSCU_PROC_CHECK=N

ENTRYPOINT ["sh", "-c", \
  "exec java $JAVA_OPTS \
    -Dport=$VSCU_PORT \
    -Dprofile=$VSCU_PROFILE \
    -Dworking_directory=$VSCU_WORKING_DIR \
    -Dno_sch_threads=$VSCU_NO_SCH_THREADS \
    -Dbatch_size=$VSCU_BATCH_SIZE \
    -Dexec_mode=$VSCU_EXEC_MODE \
    -Dlogging_level=$VSCU_LOGGING_LEVEL \
    -Dproc_check=$VSCU_PROC_CHECK \
    -jar vscu.jar \
    --spring.config.location=file:config/vscu.properties \
    --spring.main.allow-bean-definition-overriding=true \
    --spring.main.allow-circular-references=true"]
