diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..37ce71c --- /dev/null +++ b/.dockerignore @@ -0,0 +1,11 @@ +.git +.gitea +.github +.devcontainer +target +build +.gradle +k6 +k8s +overlays +*.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..94c0b9a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +# Spring PetClinic: build the jar with Maven, run it on a slim JRE. + +# Plain Maven, not ./mvnw: the Maven wrapper jar is not committed. +FROM maven:3.9-eclipse-temurin-17 AS build +WORKDIR /src +COPY pom.xml . +RUN mvn -B -q dependency:go-offline +COPY src ./src +# Tests run in integration-test.yml. Format and checkstyle checks gate on style, not on a working image. +RUN mvn -B -q package -DskipTests -Dspring-javaformat.skip=true -Dcheckstyle.skip=true + +FROM eclipse-temurin:17-jre +WORKDIR /app +COPY --from=build /src/target/*.jar app.jar +RUN useradd --system --uid 10001 app +USER 10001 +EXPOSE 8080 +ENTRYPOINT ["java", "-jar", "/app/app.jar"]