# Build stage
FROM maven:3.9.9-eclipse-temurin-21 AS build
WORKDIR /app
COPY .mvn .mvn
COPY mvnw .
COPY pom.xml .
RUN chmod +x mvnw
RUN ./mvnw -B -q dependency:go-offline
COPY src ./src
RUN ./mvnw -B clean package -DskipTests

# Runtime stage
FROM eclipse-temurin:21-jdk AS runtime
WORKDIR /app
COPY --from=build /app/target/*.jar ./app.jar
EXPOSE 8888
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar /app/app.jar"]
