152 lines
5.0 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!--
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <https://www.gnu.org/licenses/>.
*
-->
<project xmlns="http://tiles.bluetrainsoftware.com/maven/tiles/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://tiles.bluetrainsoftware.com/maven/tiles/1.1.0 https://git.inteligr8.com/inteligr8/maven-tiles/raw/xsd/src/main/resources/maven-tiles.xsd">
<build>
<plugins>
<!-- 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>
<version>3.2.0</version>
<executions>
<execution>
<id>copy-and-filter-docker-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>add-resource</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>${docker.source.directory}</directory>
<filtering>true</filtering>
<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>
<!-- want to use 'package', but needs to be after sprintboot repackage -->
<phase>pre-integration-test</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>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.39.0</version>
<configuration>
<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>
<id>docker-build</id>
<!-- want to use 'package', but needs to be after sprintboot repackage -->
<phase>pre-integration-test</phase>
<goals><goal>build</goal></goals>
<configuration>
<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</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>
</plugins>
</build>
<profiles>
<profile>
<id>default-props</id>
<activation>
<property>
<name>!some-prop-that-never-exists</name>
</property>
</activation>
<properties>
<!-- skip deployment of spring boot app -->
<beedk.deploy.dockerImageOnly>true</beedk.deploy.dockerImageOnly>
<maven.deploy.skip>${beedk.deploy.dockerImageOnly}</maven.deploy.skip>
<docker.source.directory>${basedir}/src/main/docker</docker.source.directory>
<docker.image.tag>${project.version}</docker.image.tag>
</properties>
</profile>
</profiles>
</project>