# Stage 1: Build the fat JAR
FROM gradle:8.11.1-jdk21 AS builder
WORKDIR /app
COPY gradle/ gradle/
COPY gradlew gradlew.bat build.gradle.kts settings.gradle.kts gradle.properties ./
COPY shared/ shared/
COPY server/ server/
RUN gradle :server:buildFatJar --no-daemon

# Stage 2: Run
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app
COPY --from=builder /app/server/build/libs/server.jar server.jar

ENV KRISENVORRAT_JWT_SECRET="change-me-to-a-secure-jwt-secret-at-least-32-chars"

EXPOSE 8080

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