diff --git a/documentation/guide-jib.asciidoc b/documentation/guide-jib.asciidoc new file mode 100644 index 00000000..66b22b75 --- /dev/null +++ b/documentation/guide-jib.asciidoc @@ -0,0 +1,58 @@ +:toc: +toc::[] + += JIB +jib is a tool from Google to create Docker images in simple and faster way. No dockerfile or no docker compose file is required. Using Jib, image can be created and uploaded to the registery even without Docker daemon. + +The JIB maven plugin configured to build the image using mvn command. + +== Build and run the image locally +The Docker daemon should be available locally. + +To build the docker image. +[source] +---- +mvn compile -Pcontainer + +docker images + +REPOSITORY TAG IMAGE ID CREATED SIZE +myapp-server/java 0.0.1-SNAPSHOT c521c9800c48 51 years ago 206MB +myapp-api/java 0.0.1-SNAPSHOT 7004670aa31e 51 years ago 161MB +myapp-core/java 0.0.1-SNAPSHOT 82d949c3daa3 51 years ago 205MB +---- + +To run the image. + +[source] +---- +docker run --publish 8081:8081 +---- + +== Upload the image to the registery + +No docker daemon required to be installed on your machine for this. + +The first step is to configure the registery details in .m2/settings.xml. + +[source] +---- + + + «registery» + «username» + «password» + + +---- +Keep the password encrypted (`mvn -ep`). Refer the documentation for the password encryption + https://maven.apache.org/guides/mini/guide-encryption.html + +Run the below command to create and push the image to the image repository. +[source] +---- +mvn compile -P release,container + +---- + + diff --git a/pom.xml b/pom.xml index 919bea68..a8997f09 100644 --- a/pom.xml +++ b/pom.xml @@ -32,6 +32,8 @@ 2020.0.0 2.11.2 + 2.8.0 + adoptopenjdk/openjdk11:jre-11.0.4_11-alpine 30.0-jre 5.7.0 3.4.1 diff --git a/templates/server/src/main/resources/archetype-resources/__batch__/pom.xml b/templates/server/src/main/resources/archetype-resources/__batch__/pom.xml index c9df8148..20ff72e8 100644 --- a/templates/server/src/main/resources/archetype-resources/__batch__/pom.xml +++ b/templates/server/src/main/resources/archetype-resources/__batch__/pom.xml @@ -51,5 +51,4 @@ - diff --git a/templates/server/src/main/resources/archetype-resources/api/pom.xml b/templates/server/src/main/resources/archetype-resources/api/pom.xml index 87422fa3..b8346bc0 100644 --- a/templates/server/src/main/resources/archetype-resources/api/pom.xml +++ b/templates/server/src/main/resources/archetype-resources/api/pom.xml @@ -5,7 +5,7 @@ ${groupId} ${rootArtifactId} - ${app.version} + ${app.version} ${rootArtifactId}-api jar @@ -42,4 +42,15 @@ test + + + + com.google.cloud.tools + jib-maven-plugin + + true + + + + diff --git a/templates/server/src/main/resources/archetype-resources/core/pom.xml b/templates/server/src/main/resources/archetype-resources/core/pom.xml index c32ec750..06d14d93 100644 --- a/templates/server/src/main/resources/archetype-resources/core/pom.xml +++ b/templates/server/src/main/resources/archetype-resources/core/pom.xml @@ -5,7 +5,7 @@ ${groupId} ${rootArtifactId} - ${app.version} + ${app.version} ${rootArtifactId}-core jar @@ -66,7 +66,7 @@ + --> org.springframework.boot spring-boot-starter-jdbc @@ -132,7 +132,7 @@ #elseif ($dbType == 'postgresql') org.postgresql postgresql - + #elseif ($dbType == 'mysql') mysql mysql-connector-java @@ -165,7 +165,7 @@ h2 test -#end + #end @@ -230,7 +230,7 @@ embedded - true + true diff --git a/templates/server/src/main/resources/archetype-resources/pom.xml b/templates/server/src/main/resources/archetype-resources/pom.xml index 928bb425..823c3cd0 100644 --- a/templates/server/src/main/resources/archetype-resources/pom.xml +++ b/templates/server/src/main/resources/archetype-resources/pom.xml @@ -20,17 +20,21 @@ $[guava.version] system ${revision}${changelist} + $[jib.version] + $[jib.container.image] + 8081 + buildTar api core - #if ($earProjectName != '.') +#if ($earProjectName != '.') ${earProjectName} - #end - #if ($batch == 'batch') +#end +#if ($batch == 'batch') batch - #end +#end server @@ -328,6 +332,49 @@ + + release + + build + + + + container + + true + + + + + com.google.cloud.tools + jib-maven-plugin + ${jib.version} + + + ${jib.container.image} + + + ${project.name}/java:${project.version} + + + ${package}.SpringBootApp + + ${jib.app.port} + + + + + + package + + ${jib.goal} + + + + + + + moduletest diff --git a/templates/server/src/main/resources/archetype-resources/server/pom.xml b/templates/server/src/main/resources/archetype-resources/server/pom.xml index cc0edbac..7fc7a374 100644 --- a/templates/server/src/main/resources/archetype-resources/server/pom.xml +++ b/templates/server/src/main/resources/archetype-resources/server/pom.xml @@ -5,7 +5,7 @@ ${groupId} ${rootArtifactId} - ${app.version} + ${app.version} ${rootArtifactId}-server war @@ -145,8 +145,13 @@ - + + com.google.cloud.tools + jib-maven-plugin + + true + + -