# the first stage of our build will use a maven 3.6.1 parent image
FROM maven:3.6.1-jdk-11 as builder

COPY bpmn_libs /bpmn_libs
RUN mvn install:install-file -Dfile=./bpmn_libs/org.eclipse.bpmn2-0.8.2-jboss.jar -DgroupId=org.eclipse -DartifactId=org.eclipse.bpmn2 -Dversion=0.8.2-jboss -Dpackaging=jar

COPY pom.xml .
RUN mvn dependency:go-offline && \
    mvn de.qaware.maven:go-offline-maven-plugin:resolve-dependencies -B

COPY src /src
RUN mvn -o package -DskipTests

# the second stage of our build 
FROM openjdk:11-jdk-slim

EXPOSE 8080

# copy only the artifacts we need from the first stage and discard the rest
COPY --from=builder /target/ujseEngine-1.0.0.jar /ujse.jar
COPY ./docker_info/ujse/etc/keycloak/keystore.jks /etc/keycloak/keystore.jks
ENTRYPOINT ["java","-jar","ujse.jar"]