From f7bf7c44664a9f48a8839a961680f17314dcae6e Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Tue, 28 Jan 2020 22:31:12 +0100 Subject: Maven, Gradle: Build Docker image. Change-Id: Ibf90cd31af67f847d67bd34fe1a8d73d49550088 --- build.gradle | 20 ++++++++++++++++++-- gradle.properties | 3 +++ pom.xml | 22 ++++++++++++++++++++++ src/main/docker/Dockerfile.jvm | 23 ++++++++++------------- 4 files changed, 53 insertions(+), 15 deletions(-) diff --git a/build.gradle b/build.gradle index ae57661..374b627 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,7 @@ plugins { id 'java' id 'io.quarkus' + id "com.bmuschko.docker-remote-api" version "${dockerPluginVersion}" id "com.diffplug.gradle.spotless" version "${spotlessPluginVersion}" id "com.github.ben-manes.versions" version "${versionsPluginVersion}" id "se.patrikerdes.use-latest-versions" version "${useLatestVersionsPluginVersion}" @@ -85,8 +86,8 @@ spotless { } } -group 'eu.mulk' -version '0.1.0-SNAPSHOT' +group "eu.mulk" +version "${projectVersion}" task yarnInstall(type:Exec) { workingDir "src/main/resources/META-INF/resources" @@ -113,3 +114,18 @@ processResources { } quarkusBuild.dependsOn compileWeb + +task buildDocker(type: com.bmuschko.gradle.docker.tasks.image.DockerBuildImage) { + inputDir = file(".") + dockerFile = file("src/main/docker/Dockerfile.jvm") + images.add("docker.benkard.de/mulk/mulkcms2:${projectVersion}") +} + +buildDocker.dependsOn quarkusBuild +assemble.dependsOn buildDocker + +task pushDocker(type: com.bmuschko.gradle.docker.tasks.image.DockerPushImage) { + images.add("docker.benkard.de/mulk/mulkcms2:${projectVersion}") +} + +pushDocker.dependsOn buildDocker diff --git a/gradle.properties b/gradle.properties index d7dc937..f607976 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,5 @@ +projectVersion = 0.1.0-SNAPSHOT + quarkusPlatformGroupId = io.quarkus #quarkusPlatformArtifactId = quarkus-universe-bom @@ -9,6 +11,7 @@ quarkusPluginVersion = 1.2.0.Final #quarkusPlatformVersion = 999-SNAPSHOT #quarkusPluginVersion = 999-SNAPSHOT +dockerPluginVersion = 6.1.3 spotlessPluginVersion = 3.27.1 versionsPluginVersion = 0.27.0 useLatestVersionsPluginVersion = 0.2.13 diff --git a/pom.xml b/pom.xml index 3fcdc0d..a20aed5 100644 --- a/pom.xml +++ b/pom.xml @@ -17,6 +17,7 @@ UTF-8 3.8.1 + 1.4.13 1.2.0.Final 3.0.0-M4 1.26.1 @@ -291,6 +292,27 @@ + + + com.spotify + dockerfile-maven-plugin + ${dockerfile-plugin.version} + + + default + + build + push + + + + + src/main/docker/Dockerfile.jvm + docker.benkard.de/mulk/mulkcms2 + ${project.version} + + + diff --git a/src/main/docker/Dockerfile.jvm b/src/main/docker/Dockerfile.jvm index c7ff48c..5c726c5 100644 --- a/src/main/docker/Dockerfile.jvm +++ b/src/main/docker/Dockerfile.jvm @@ -7,28 +7,25 @@ # # Then, build the image with: # -# docker build -f src/main/docker/Dockerfile.jvm -t quarkus/mulkcms2-jvm . +# docker build -f src/main/docker/Dockerfile.jvm -t docker.benkard.de/mulk/mulkcms2 . # # Then run the container using: # -# docker run -i --rm -p 8080:8080 quarkus/mulkcms2-jvm +# docker run -i --rm -p 8080:8080 docker.benkard.de/mulk/mulkcms2 # ### -FROM fabric8/java-alpine-openjdk8-jre:1.6.5 -ENV JAVA_OPTIONS="-Dquarkus.http.host=0.0.0.0 -Djava.util.logging.manager=org.jboss.logmanager.LogManager" -ENV AB_ENABLED=jmx_exporter +FROM adoptopenjdk:13-jre-hotspot -# Be prepared for running in OpenShift too -RUN adduser -G root --no-create-home --disabled-password 1001 \ - && chown -R 1001 /deployments \ +RUN mkdir -p /deployments + +RUN useradd --user-group --uid 1200 java \ + && chown -R java /deployments \ && chmod -R "g+rwX" /deployments \ - && chown -R 1001:root /deployments + && chown -R java:java /deployments COPY build/lib/* /deployments/lib/ COPY build/*-runner.jar /deployments/app.jar EXPOSE 8080 -# run with user 1001 -USER 1001 - -ENTRYPOINT [ "/deployments/run-java.sh" ] \ No newline at end of file +USER java +ENTRYPOINT ["java", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseShenandoahGC", "-XX:ShenandoahGCHeuristics=compact", "-Dquarkus.http.host=0.0.0.0", "-Djava.util.logging.manager=org.jboss.logmanager.LogManager", "-jar", "/deployments/app.jar"] -- cgit v1.2.3