FROM eclipse-temurin:21-jdk-alpine

WORKDIR /highbyte
COPY ./HighByte-Intelligence-Hub-4.3.1/appData/ /highbyte/appData
COPY ./HighByte-Intelligence-Hub-4.3.1/runtime/ /highbyte/runtime
COPY ./HighByte-Intelligence-Hub-4.3.1/configuration /highbyte/configuration

# Make script executable
RUN chmod +x /highbyte/runtime/start-linux.sh

# Default environment variables
ENV OTEL_AGENT_JAR="" \
    JAVA_OPTS="" \
    OTEL_ENDPOINT="http://localhost:4318"\
    START_MODE="Default"\
    HA_NODE="node1"\
    HA_URI="jdbc:postgresql://pgdb-service:5432/dbName?user=username&password=password"

# Suggested ports
EXPOSE 45245
EXPOSE 1885
EXPOSE 8885
EXPOSE 45345
EXPOSE 9001

# USER defines user the container will be run as. 
RUN adduser highbyteuser -D
RUN chown -R highbyteuser /highbyte
USER highbyteuser

# Entrypoint runs the start script
ENTRYPOINT ["/highbyte/runtime/start-linux.sh"]