diff options
| author | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-07-19 16:37:49 +0200 |
|---|---|---|
| committer | Fabian Mastenbroek <mail.fabianm@gmail.com> | 2020-08-24 19:48:10 +0200 |
| commit | 8ecb607dc6b54ff7a37fc0fea4f1a896dc5e7015 (patch) | |
| tree | 565f2635a5a42f919177fbf6239b3d3dfb56701b /simulator/Dockerfile | |
| parent | 55c7dd85f2cf215c302c4bb9f21a15d9dc2b489d (diff) | |
Cache build artifacts for Docker build
Diffstat (limited to 'simulator/Dockerfile')
| -rw-r--r-- | simulator/Dockerfile | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/simulator/Dockerfile b/simulator/Dockerfile index 852809b3..e42c7f14 100644 --- a/simulator/Dockerfile +++ b/simulator/Dockerfile @@ -1,11 +1,31 @@ -FROM gradle:jdk14 +FROM openjdk:14-slim AS staging MAINTAINER OpenDC Maintainers <opendc@atlarge-research.com> -COPY ./ /simulator -RUN cd /simulator/ \ - && gradle --no-daemon :opendc:opendc-runner-web:installDist +# Build staging artifacts for dependency caching +COPY ./ /app +WORKDIR /app +RUN mkdir /staging \ + && cp -r buildSrc/ /staging \ + && cp gradle.properties /staging 2>/dev/null | true \ + && find -name "*.gradle.kts" | xargs cp --parents -t /staging -FROM openjdk:14 -COPY --from=0 /simulator/opendc/opendc-runner-web/build/install /simulator -WORKDIR /simulator +FROM openjdk:14-slim AS builder + +# Obtain (cache) Gradle wrapper +COPY gradlew /app/ +COPY gradle /app/gradle +WORKDIR /app +RUN ./gradlew --version + +# Install (cache) project dependencies only +COPY --from=staging /staging/ /app/ +RUN ./gradlew clean build --no-daemon > /dev/null 2>&1 || true + +# Build project +COPY ./ /app/ +RUN ./gradlew --no-daemon :opendc:opendc-runner-web:installDist + +FROM openjdk:14-slim +COPY --from=builder /app/opendc/opendc-runner-web/build/install /app +WORKDIR /app CMD opendc-runner-web/bin/opendc-runner-web |
