# Stage 1: Build the app
FROM eclipse-temurin:21-jdk-alpine AS builder

WORKDIR /app

# Copy the entire source code to the container
COPY . .

# Build project without tests, output is in build/libs/
RUN ./gradlew clean build -x test

# Stage 2: Run the app
FROM eclipse-temurin:21-jdk-alpine

WORKDIR /app

# Copy any jar from build/libs and rename to app.jar
COPY --from=builder /app/build/libs/*.jar app.jar

EXPOSE 8080

ENTRYPOINT ["java", "-jar", "app.jar"]
