From fc5405bab041545f4b7f04faa22fb21cc84f5c43 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Thu, 16 Jul 2020 22:30:57 +0200 Subject: Add docker-compose service for simulator This change re-adds the simulator service for the docker-compose configuration, such that it will listen for incoming jobs from the API. --- simulator/Dockerfile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 simulator/Dockerfile (limited to 'simulator/Dockerfile') diff --git a/simulator/Dockerfile b/simulator/Dockerfile new file mode 100644 index 00000000..c923cddf --- /dev/null +++ b/simulator/Dockerfile @@ -0,0 +1,27 @@ +FROM gradle:jdk14 +MAINTAINER OpenDC Maintainers + +# Set the home directory to our gradle user's home. +ENV HOME=/home/gradle +ENV APP_HOME=$HOME/simulator + +# Copy OpenDC simulator +COPY ./ $APP_HOME + +# Build as root +USER root + +# Set the working directory to the simulator +WORKDIR $APP_HOME + +# Build the application +RUN gradle --no-daemon assemble installDist + +# Fix permissions +RUN chown -R gradle:gradle $APP_HOME + +# Downgrade user +USER gradle + +# Start the Gradle application on run +CMD opendc/opendc-runner-web/build/install/opendc-runner-web/bin/opendc-runner-web -- cgit v1.2.3 From 0a895abfe307fbb6a28ceac6a07c5ac4863627fd Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Fri, 17 Jul 2020 17:25:45 +0200 Subject: Add data processing pipeline via Spark This change adds support for processing the experimental results by means of a Spark data processing pipeline. --- simulator/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'simulator/Dockerfile') diff --git a/simulator/Dockerfile b/simulator/Dockerfile index c923cddf..7daa8a2e 100644 --- a/simulator/Dockerfile +++ b/simulator/Dockerfile @@ -15,7 +15,7 @@ USER root WORKDIR $APP_HOME # Build the application -RUN gradle --no-daemon assemble installDist +RUN gradle --no-daemon :opendc:opendc-runner-web:installDist # Fix permissions RUN chown -R gradle:gradle $APP_HOME -- cgit v1.2.3 From 55c7dd85f2cf215c302c4bb9f21a15d9dc2b489d Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Sat, 18 Jul 2020 17:22:47 +0200 Subject: Make simulator image leaner This change updates the Dockerfile for the simulator to reduce its size. By using Docker stages, we can split the build image from the runtime image that only contains the runtime binaries. --- simulator/Dockerfile | 32 ++++++++------------------------ 1 file changed, 8 insertions(+), 24 deletions(-) (limited to 'simulator/Dockerfile') diff --git a/simulator/Dockerfile b/simulator/Dockerfile index 7daa8a2e..852809b3 100644 --- a/simulator/Dockerfile +++ b/simulator/Dockerfile @@ -1,27 +1,11 @@ FROM gradle:jdk14 MAINTAINER OpenDC Maintainers -# Set the home directory to our gradle user's home. -ENV HOME=/home/gradle -ENV APP_HOME=$HOME/simulator - -# Copy OpenDC simulator -COPY ./ $APP_HOME - -# Build as root -USER root - -# Set the working directory to the simulator -WORKDIR $APP_HOME - -# Build the application -RUN gradle --no-daemon :opendc:opendc-runner-web:installDist - -# Fix permissions -RUN chown -R gradle:gradle $APP_HOME - -# Downgrade user -USER gradle - -# Start the Gradle application on run -CMD opendc/opendc-runner-web/build/install/opendc-runner-web/bin/opendc-runner-web +COPY ./ /simulator +RUN cd /simulator/ \ + && gradle --no-daemon :opendc:opendc-runner-web:installDist + +FROM openjdk:14 +COPY --from=0 /simulator/opendc/opendc-runner-web/build/install /simulator +WORKDIR /simulator +CMD opendc-runner-web/bin/opendc-runner-web -- cgit v1.2.3 From 8ecb607dc6b54ff7a37fc0fea4f1a896dc5e7015 Mon Sep 17 00:00:00 2001 From: Fabian Mastenbroek Date: Sun, 19 Jul 2020 16:37:49 +0200 Subject: Cache build artifacts for Docker build --- simulator/Dockerfile | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'simulator/Dockerfile') 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 -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 -- cgit v1.2.3