I'm trying to Dockerize Spring Microservices application with the help of Jib. Config of parent pom.xml:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.nikonenko</groupId>
<artifactId>microservices</artifactId>
<packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version>
<modules>
<module>library-service</module>
<module>book-service</module>
<module>discovery-server</module>
<module>api-gateway</module>
<module>config-service</module>
<module>authentication-service</module>
</modules>
<name>microservices</name>
<description>..</description>
<properties>
<java.version>17</java.version>
<spring-cloud.version>2023.0.0</spring-cloud.version>
<maven.compiler.source>19</maven.compiler.source>
<maven.compiler.target>19</maven.compiler.target>
</properties>
<dependencies>
*dependencies*
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.0</version>
<configuration>
<from>
<image>eclipse-temurin:17.0.4.1_1-jre</image>
</from>
<to>
<image>registry.hub.docker.com/viktordiktor/${project.artifactId}</image>
</to>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>dockerBuild</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
So, when I'm use mvn clean compile jib:build
, I'm getting this error:
[ERROR] Failed to execute goal com.google.cloud.tools:jib-maven-plugin:3.4.0:build (default-cli) on project library-service: Missing target image parameter, perhaps you should add a configuration parameter to your pom.xml or set the parameter via the commandline (e.g. 'mvn compile jib:build -Dimage='). -> [Help 1]
I also changed my settings.xml file:
<servers>
<id>registry.hub.docker.com</id>
<username>username</username>
<password>pass</password>
</servers>
When you want to propagate the invocation of a plugin to the modules of a multi-module Maven project, you need to put it to the pluginManagement
block of the parent POM:
<build>
<!-- Defines plugins that are used in the modules. -->
<pluginManagement>
<plugins>
<plugin>
<groupId>com.google.cloud.tools</groupId>
<artifactId>jib-maven-plugin</artifactId>
<version>3.4.0</version>
</plugin>
</plugins>
</pluginManagement>
</build>
See an example provided by Jib.