diff --git a/.dockerignore b/.dockerignore index f9ff432..529cc36 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,17 +1,23 @@ +# Ignore everything +* -# IDE -.idea/ -.vscode/ -.gradle/ -.settings/ +# Allow files and directories +!/.git +!/src +!/.editorconfig +!/.gitattributes +!/.gitignore +!/build.gradle +!/gradle.properties +!/gradlew +!/gradlew.bat +!/morny-github-social-preview-card@0.75x.png +!/README.md +!/settings.gradle -#build -/build/ -/bin/ -.metals/ -.bloop/ -.project -lcoal.properties - -# debug dir -/run/ +# Ignore unnecessary files inside allowed directories +# This should go after the allowed directories +**/*~ +**/*.log +**/.DS_Store +**/Thumbs.db diff --git a/Dockerfile b/Dockerfile index 055ebfc..79bde1a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,21 +1,25 @@ -FROM eclipse-temurin:20-jdk as build -LABEL authors="A.C.Sukazyo Eyre" +FROM gradle:8.8-jdk21 AS build-base + +WORKDIR /build + +COPY ./build.gradle ./settings.gradle ./gradle.properties /build/ + +RUN gradle buildEnvironment +RUN gradle dependencies + +FROM build-base AS build + +WORKDIR /build + +COPY . /build/ + +RUN gradle shadowJar -PdockerBuild + +FROM eclipse-temurin:20-jre AS app -COPY . /app/source/ WORKDIR /app -RUN cd ./source \ -&& ./gradlew shadowJar -PdockerBuild \ -&& cd .. \ -&& cp ./source/build/libs/morny-coeur-docker-build.jar ./morny-coeur.jar -#&& rm -r ./source \ -#&& rm -r /root/.gradle \ - - -FROM eclipse-temurin:20-jre - -COPY --from=build /app/morny-coeur.jar /app/morny-coeur.jar -WORKDIR /app +COPY --from=build /build/build/libs/morny-coeur-docker-build.jar /app/morny-coeur.jar ENTRYPOINT ["java", "-jar", "morny-coeur.jar"] CMD ["-q", "-v"]