Files
ai-teacher/backend/Dockerfile.native
T
2026-04-09 22:09:25 +02:00

26 lines
901 B
Docker

# ---- Pull Maven from its official image (avoids microdnf under QEMU) ----
FROM docker.io/library/maven:3.9.9-eclipse-temurin-21 AS maven-dist
# ---- Build stage: GraalVM 25 + Maven ----
FROM ghcr.io/graalvm/native-image-community:25 AS build
# Copy Maven from the official Maven image — no package installation needed
COPY --from=maven-dist /usr/share/maven /opt/maven
ENV PATH="/opt/maven/bin:$PATH"
WORKDIR /app
# Cache dependency resolution separately from source compilation
COPY pom.xml .
RUN mvn -Pnative dependency:resolve dependency:resolve-plugins -q
# Build native executable
COPY src ./src
RUN mvn -Pnative package -DskipTests
# ---- Runtime stage: distroless with glibc + libz (required by GraalVM native binary) ----
FROM gcr.io/distroless/base-debian12
COPY --from=build /app/target/ai-teacher-backend /app/ai-teacher-backend
EXPOSE 8080
ENTRYPOINT ["/app/ai-teacher-backend"]