<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
 * Copyright (c) Codice Foundation
 *
 * This 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 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 Lesser General Public License for more details. A copy of the GNU Lesser General Public License is distributed along with this program and can be found at
 * <http://www.gnu.org/licenses/lgpl.html>.
 *
 **/
-->
<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>ddf.distribution</groupId>
        <artifactId>docker</artifactId>
        <version>2.29.33</version>
    </parent>
    <artifactId>ddf-docker</artifactId>
    <groupId>ddf.distribution.docker</groupId>
    <packaging>pom</packaging>
    <name>DDF :: Distribution :: Docker :: DDF</name>

    <properties>
        <!-- Set the version of the codice/ddf-base docker image to build on top of here -->
        <docker.ddf.base.version>2.29-alpine</docker.ddf.base.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.codice.ddf</groupId>
            <artifactId>ddf</artifactId>
            <version>${project.version}</version>
            <type>zip</type>
            <!-- Exclude all transitives of the ddf distribution.
              This ensures that extra files are not sent to the docker daemon
              as part of the build context. -->
            <exclusions>
                <exclusion>
                  <groupId>*</groupId>
                  <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <profiles>
        <profile>
            <!-- The docker profile activates automatically on linux systems
              otherwise docker builds will be skipped. This will be removed in the future 
              once testing has been done on running docker builds cross-platform. -->
            <id>docker</id>
            <activation>
                <os>
                    <family>unix</family>
                    <name>Linux</name>
                </os>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <configuration>
                            <images>
                                <image>
                                    <name>docker.io/codice/ddf:${project.version}</name>
                                    <build>
                                        <dockerFile>Dockerfile</dockerFile>
                                        <assembly>
                                            <descriptor>files.xml</descriptor>
                                        </assembly>
                                    </build>
                                </image>
                            </images>
                        </configuration>
                        <executions>
                            <execution>
                                <id>build-ddf-image</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <phase>install</phase>
                            </execution>
                            <execution>
                                <id>push-ddf-image</id>
                                <phase>deploy</phase>
                                <goals>
                                    <goal>push</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
