# Image de base 
FROM maven:3-eclipse-temurin-17-alpine as build_image

# Passage dans le repertoire de compilation
WORKDIR /sources

# Copie des sources
COPY src src
COPY pom.xml pom.xml

# Lancement du package
RUN mvn package

# Runtime Image
FROM eclipse-temurin:17-jre-alpine

# Environment variables
ENV UID=2000
ENV GID=4000

# Changement d'utilisateur
USER ${UID}:${GID}

# Copie du jar
COPY --from=build_image --chown=${UID}:${GID} /sources/target/fbapp.jar .
RUN ls -l

# Lancement de l'application
CMD ["java", "-jar", "fbapp.jar"]