swiched from spotify to fabric8 docker plugin

This commit is contained in:
Brian Long 2022-02-24 11:31:54 -05:00
parent 6ea6faa327
commit 856c6f4afa

View File

@ -5,8 +5,8 @@
<build>
<plugins>
<!-- This plugin copies the Dockerfile and resources to the base build directory -->
<!-- Dockerfile ADD/COPY commands can only use files inside the build directory -->
<!-- This plugin copies the Dockerfile and resources to the base context build directory -->
<!-- Dockerfile ADD/COPY commands can only use files inside the context build directory -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
@ -23,26 +23,60 @@
<resource>
<directory>${docker.source.directory}</directory>
<filtering>true</filtering>
<targetPath>${project.build.directory}</targetPath>
<targetPath>${project.build.directory}/docker/context</targetPath>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<!-- This plugin copies the Spring Boot JAR to the base build context directory -->
<!-- Dockerfile ADD/COPY commands can only use files inside the context build directory -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-jar</id>
<phase>package</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${project.build.directory}</directory>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>
<outputDirectory>${project.build.directory}/docker/context</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!-- This plugin configures the building and pushing of a Docker image -->
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.4.13</version>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.39.0</version>
<configuration>
<contextDirectory>${project.build.directory}</contextDirectory>
<repository>${docker.image.registry}/${docker.image.name}</repository>
<tag>${docker.image.tag}</tag>
<useMavenSettingsForAuth>true</useMavenSettingsForAuth>
<buildArgs>
<JAR_FILE>${project.artifactId}-${project.version}.jar</JAR_FILE>
</buildArgs>
<images>
<image>
<name>${docker.image.name}</name>
<alias>${artifactId}-docker-image</alias>
<build>
<contextDir>${project.build.directory}/docker/context</contextDir>
<args>
<JAR_FILE>${project.artifactId}-${project.version}.jar</JAR_FILE>
</args>
<tags>
<tag>${docker.image.tag}</tag>
</tags>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
@ -50,18 +84,29 @@
<phase>package</phase>
<goals><goal>build</goal></goals>
<configuration>
<repository>${docker.image.name}</repository>
<skipPush>true</skipPush>
<skipTag>false</skipTag> <!-- BUG workaround -->
</configuration>
</execution>
<!-- BUG: artifactId appears to be automatically appended to docker.image.name
add tag to build for now -->
<!--
<execution>
<id>docker-tag-registry</id>
<id>docker-tag</id>
<phase>install</phase>
<goals><goal>tag</goal></goals>
<configuration>
<tagName>${docker.image.tag}</tagName>
</configuration>
</execution>
-->
<execution>
<id>docker-push</id>
<phase>deploy</phase>
<goals><goal>push</goal></goals>
<configuration>
<pushRegistry>${docker.image.registry}</pushRegistry>
</configuration>
</execution>
</executions>
</plugin>