# ----------------------------------------------------------------------- #
FROM docker.io/library/gradle:9.2-jdk AS builder
WORKDIR /
COPY ./src/ ./src/
COPY ./build.gradle.kts ./
COPY ./gradle.properties ./
COPY ./settings.gradle.kts ./
RUN gradle build --no-daemon

# ----------------------------------------------------------------------- #
#FROM alpine/java:21-jdk AS run

#COPY --from=builder /build/libs/kontor-quarkus-0.2.0-SNAPSHOT.jar app.jar

#EXPOSE 8300
#CMD ["java", "-jar", "-Dquarkus.http.host=0.0.0.0", "app.jar"]

# ----------------------------------------------------------------------- #
FROM registry.access.redhat.com/ubi9/openjdk-21:1.23

ENV LANGUAGE='de_DE:de'

# We make four distinct layers so if there are application changes the library layers can be re-used
COPY --from=builder build/quarkus-app/lib/ /deployments/lib/
COPY --from=builder build/quarkus-app/*.jar /deployments/
COPY --from=builder build/quarkus-app/app/ /deployments/app/
COPY --from=builder build/quarkus-app/quarkus/ /deployments/quarkus/

EXPOSE 8300
ENV JAVA_OPTS_APPEND="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager"
ENV JAVA_APP_JAR="/deployments/quarkus-run.jar"

ENTRYPOINT [ "/opt/jboss/container/java/run/run-java.sh" ]
