Skip to content

Commit

Permalink
add caching stage to docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
zingmane committed Nov 30, 2023
1 parent 542382c commit 1a197fc
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
FROM gradle:7.4.1-jdk17 as builder
FROM gradle:7.4.1-jdk17 as cacher
ENV APP_HOME=/usr/src/app
ENV GRADLE_USER_HOME /cache
WORKDIR $APP_HOME
COPY build.gradle gradle.properties settings.gradle ./
RUN gradle --no-daemon testClasses assemble \
# prevent errors from spotless b/c in cacher stage we have no source files yet
-x spotlessScala

FROM gradle:7.4.1-jdk17 as builder
ENV GRADLE_USER_HOME /cache
WORKDIR $APP_HOME
COPY --from=cacher /cache /cache
COPY --chown=gradle:gradle . $APP_HOME
# RUN ls -rtla $APP_HOME
RUN gradle -v \
&& gradle testClasses assemble \
&& mv conf-jenkins.json conf-test.json

FROM gradle:7.4.1-jdk17 as tester
WORKDIR $APP_HOME
COPY --from=builder . .
RUN gradle test

FROM openjdk:22-slim as prod
WORKDIR $APP_HOME
COPY --from=builder --chown=campudus:campudus ./build/libs/grud-backend-0.1.0-fat.jar ./tableaux-fat.jar
Expand Down

0 comments on commit 1a197fc

Please sign in to comment.