# use an official maven image and alias this with the name builder
FROM maven:3.9.9-amazoncorretto-21-alpine AS builder
# set the working directory in the container
WORKDIR /app
# copy entire backend folder structure to container
COPY . .
# build the application using maven skipping any tests
RUN mvn clean package -DskipTests

# use an official java base image
FROM amazoncorretto:21-alpine-jdk
# set the working directory in the container
WORKDIR /app
# copy the built jar from the previous stage to the container
COPY --from=builder /app/target/*.jar app.jar
# set the command to run the application and configure as an executable
ENTRYPOINT [ "java", "-jar", "app.jar" ]
