<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>fish.focus.uvms.docker</groupId>
		<artifactId>uvms-docker</artifactId>
		<version>4.2.2</version>
		<relativePath>../pom.xml</relativePath>
	</parent>
	<artifactId>uvms-docker-wildfly-base</artifactId>
	<packaging>pom</packaging>
	<name>uvms-docker-wildfly-base</name>
	<properties>
		<wildfly.hibernate.module.spatial.version>5.4.1.Final</wildfly.hibernate.module.spatial.version>
		<wildfly.hibernate.module.geolatte.version>1.4.0</wildfly.hibernate.module.geolatte.version>
		<wildfly.hibernate.module.jts.version>1.16.1</wildfly.hibernate.module.jts.version>
		<wildfly.postgres.module.postgis.version>2.5.1</wildfly.postgres.module.postgis.version>
		<wildfly.postgres.module.postgres.version>42.3.3</wildfly.postgres.module.postgres.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-core</artifactId>
			<version>${wildfly.hibernate.module.spatial.version}</version>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-envers</artifactId>
			<version>${wildfly.hibernate.module.spatial.version}</version>
		</dependency>
		<dependency>
			<groupId>org.hibernate</groupId>
			<artifactId>hibernate-spatial</artifactId>
			<version>${wildfly.hibernate.module.spatial.version}</version>
		</dependency>
		<dependency>
			<groupId>org.geolatte</groupId>
			<artifactId>geolatte-geom</artifactId>
			<version>${wildfly.hibernate.module.geolatte.version}</version>
		</dependency>
		<dependency>
			<groupId>org.locationtech.jts</groupId>
			<artifactId>jts-core</artifactId>
			<version>${wildfly.hibernate.module.jts.version}</version>
		</dependency>
		<dependency>
			<groupId>org.postgresql</groupId>
			<artifactId>postgresql</artifactId>
			<version>${wildfly.postgres.module.postgres.version}</version>
		</dependency>
		<dependency>
			<groupId>net.postgis</groupId>
			<artifactId>postgis-jdbc</artifactId>
			<version>${wildfly.postgres.module.postgis.version}</version>
		</dependency>
		<dependency>
			<groupId>net.postgis</groupId>
			<artifactId>postgis-geometry</artifactId>
			<version>${wildfly.postgres.module.postgis.version}</version>
		</dependency>
	</dependencies>
	<build>
		<pluginManagement>
			<plugins>
				<plugin>
					<groupId>io.fabric8</groupId>
					<artifactId>docker-maven-plugin</artifactId>
					<version>0.39.1</version>
				</plugin>
			</plugins>
		</pluginManagement>
		<plugins>
			<!-- 
			<plugin>
				<groupId>org.codehaus.mojo</groupId>
				<artifactId>keytool-maven-plugin</artifactId>
				<version>1.5</version>
				<executions>
					<execution>
						<id>generateKeyPair</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>generateKeyPair</goal>
						</goals>
						<configuration>
							<alias>wildflybaselocalhost</alias>
							<dname>cn=localhost, ou=None, L=None, ST=None, o=None, c=SE</dname>
							<sigalg>SHA256withRSA</sigalg>
							<ext />
							<validity>3650</validity>
							<keyalg>RSA</keyalg>
							<keysize>4096</keysize>
						</configuration>
					</execution>
					<execution>
						<id>removekeystore</id>
						<phase>clean</phase>
						<goals>
							<goal>clean</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<keystore>${project.basedir}/target/dockerfile/server.keystore</keystore>
					<storepass>keypassword</storepass>
					<storetype>JKS</storetype>
					<keypass>keypassword</keypass>
					<skipIfExist>true</skipIfExist>
				</configuration>
			</plugin>
			-->
			<plugin>
				<artifactId>maven-resources-plugin</artifactId>
				<executions>
					<execution>
						<id>filter-resources</id>
						<phase>validate</phase>
						<goals>
							<goal>resources</goal>
						</goals>
						<configuration>
							<outputDirectory>${project.basedir}/target/dockerfile</outputDirectory>
							<resources>
								<resource>
									<directory>${project.basedir}/src/main/docker</directory>
									<filtering>false</filtering>
									<excludes>
										<exclude>Dockerfile</exclude>
										<exclude>**/module.xml</exclude>
									</excludes>
								</resource>
								<resource>
									<directory>${project.basedir}/src/main/docker/</directory>
									<filtering>true</filtering>
									<includes>
										<include>Dockerfile</include>
										<include>**/module.xml</include>
									</includes>
								</resource>
							</resources>
						</configuration>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-dependency-plugin</artifactId>
				<version>3.3.0</version>
				<executions>
					<execution>
						<id>copy-dependencies</id>
						<phase>generate-resources</phase>
						<goals>
							<goal>copy-dependencies</goal>
						</goals>
						<configuration>
							<copyPom>false</copyPom>
							<outputDirectory>${project.basedir}/target/dockerfile/dependencies</outputDirectory>
							<excludeTypes>pom</excludeTypes>
							<prependGroupId>false</prependGroupId>
							<excludeTransitive>true</excludeTransitive>
						</configuration>
					</execution>
				</executions>
			</plugin>					
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<version>3.3.0</version>
				<configuration>
					<descriptors>
						<descriptor>src/main/assembly/assembly.xml</descriptor>
					</descriptors>
					<finalName>${project.artifactId}</finalName>
					<appendAssemblyId>false</appendAssemblyId>
				</configuration>
				<executions>
					<execution>
						<phase>package</phase>
						<goals>
							<goal>single</goal>
						</goals>
					</execution>
				</executions>
			</plugin>
			<plugin>
				<groupId>org.apache.maven.plugins</groupId>
				<artifactId>maven-deploy-plugin</artifactId>
				<goals>
					<goal>deploy-file</goal>
				</goals>
				<configuration>
					<packaging>zip</packaging>
					<generatePom>true</generatePom>
					<artifactId>${project.artifactId}</artifactId>
					<groupId>${project.groupId}</groupId>
					<version>${project.version}</version>
					<file>target/${project.artifactId}.zip</file>
				</configuration>
			</plugin>									
			<plugin>
				<groupId>io.fabric8</groupId>
				<artifactId>docker-maven-plugin</artifactId>
				<executions>
					<execution>
						<id>package</id>
						<phase>package</phase>
						<goals>
							<goal>build</goal>
						</goals>
					</execution>
					<execution>
						<id>verifyallstopped</id>
						<phase>compile</phase>
						<goals>
							<goal>stop</goal>
						</goals>
					</execution>
					<execution>
						<id>stoppall</id>
						<phase>install</phase>
						<goals>
							<goal>stop</goal>
						</goals>
					</execution>
				</executions>
				<configuration>
					<images>
						<image>
							<alias>postgres</alias>
							<name>uvms/postgres-release:${project.version}</name>
							<run>
								<net>bridge</net>
								<namingStrategy>none</namingStrategy>
								<ports>
									<port>25432:5432</port>
								</ports>
								<wait>
									<log>All uvms databases created</log>
									<time>480000</time>
									<kill>15000</kill>
									<shutdown>15000</shutdown>
								</wait>
								<log>
									<enabled>true</enabled>
									<color>green</color>
								</log>
								<hostname>postgres</hostname>
							</run>
						</image>
						<image>
							<name>uvms/wildfly-base:${project.version}</name>
							<build>
								<args>
									<WILDFLY_VERSION>${unionvms.wildfly.version}</WILDFLY_VERSION>
								</args>
								<dockerFileDir>${project.basedir}/target/dockerfile</dockerFileDir>
							</build>
							<run>
								<net>bridge</net>
								<namingStrategy>none</namingStrategy>
								<links>
									<link>postgres:postgres</link>
								</links>
								<ports>
									<port>29990:9990</port>
									<port>28787:8787</port>
									<port>28080:8080</port>
									<port>28443:8443</port>
								</ports>
								<wait>
									<http>
										<url>http://localhost:28080/</url>
										<method>GET</method>
										<status>200</status>
									</http>
									<time>900000</time>
									<kill>15000</kill>
									<shutdown>15000</shutdown>
								</wait>
								<cmd>
									<shell>/opt/jboss/start.sh /opt/jboss/wildfly/bin/standalone.sh
										-c standalone-full.xml -b 0.0.0.0 -bmanagement 0.0.0.0 --debug</shell>
								</cmd>
								<dependsOn>
									<container>postgres</container>
								</dependsOn>
								<volumes>
									<bind>
										<volume>${docker.volume.app.logs}:/app/logs</volume>
										<volume>${docker.volume.server.logs}:/opt/jboss/wildfly/standalone/log</volume>
									</bind>
								</volumes>
								<log>
									<enabled>true</enabled>
									<color>blue</color>
								</log>
								<hostname>wildfly</hostname>
							</run>

						</image>
					</images>
				</configuration>
			</plugin>
		</plugins>
	</build>
	<profiles>
		<profile>
			<id>push-docker</id>
			<activation>
				<property>
					<name>performRelease</name>
					<value>true</value>
				</property>
			</activation>
			<build>
				<plugins>
					<plugin>
						<groupId>io.fabric8</groupId>
						<artifactId>docker-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>docker:push</id>
								<phase>install</phase>
								<goals>
									<goal>push</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>
	<scm>
		<tag>HEAD</tag>
	</scm>
</project>
