<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>content-services-community-docker-alfresco</artifactId>
    <name>ACS Community Docker Image Builder for Alfresco Community</name>
    <packaging>pom</packaging>

    <parent>
        <groupId>org.alfresco</groupId>
        <artifactId>acs-community-packaging</artifactId>
        <version>6.0.5-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <properties>
        <image.name>alfresco/alfresco-content-repository-community</image.name>
        <image.registry>quay.io</image.registry>
        <public.image.registry>registry.hub.docker.com</public.image.registry>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>content-services-community</artifactId>
            <version>${project.version}</version>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>alfresco-server-root</artifactId>
            <version>${dependency.alfresco-server-root.version}</version>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>${dependency.postgresql.version}</version>
        </dependency>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>alfresco-mmt</artifactId>
            <version>${dependency.alfresco-mmt.version}</version>
        </dependency>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>alfresco-share-services</artifactId>
            <version>${alfresco.alfresco-share-services.version}</version>
            <type>amp</type>
        </dependency>
        <dependency>
            <groupId>org.alfresco.aos-module</groupId>
            <artifactId>alfresco-aos-module</artifactId>
            <version>${alfresco.aos-module.version}</version>
            <type>amp</type>
        </dependency>
        <dependency>
            <groupId>org.alfresco.aos-module</groupId>
            <artifactId>alfresco-vti-bin</artifactId>
            <version>${alfresco.aos-module.version}</version>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>org.alfresco.integrations</groupId>
            <artifactId>alfresco-googledocs-repo</artifactId>
            <version>${alfresco.googledocs.version}</version>
            <type>amp</type>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>3.0.2</version>
                <executions>
                    <execution>
                        <id>unpack-resources</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.alfresco</groupId>
                                    <artifactId>content-services-community</artifactId>
                                    <version>${project.version}</version>
                                    <type>war</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/war/alfresco</outputDirectory>
                                    <destFileName>alfresco.war</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-resources-war</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.postgresql</groupId>
                                    <artifactId>postgresql</artifactId>
                                    <version>${dependency.postgresql.version}</version>
                                    <type>jar</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/connector</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.alfresco</groupId>
                                    <artifactId>alfresco-mmt</artifactId>
                                    <version>${dependency.alfresco-mmt.version}</version>
                                    <type>jar</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/alfresco-mmt</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.alfresco</groupId>
                                    <artifactId>alfresco-server-root</artifactId>
                                    <version>${dependency.alfresco-server-root.version}</version>
                                    <type>war</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/server-root</outputDirectory>
                                    <destFileName>ROOT.war</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>

                    <execution>
                        <id>copy-resources-amps</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.alfresco</groupId>
                                    <artifactId>alfresco-share-services</artifactId>
                                    <version>${alfresco.alfresco-share-services.version}</version>
                                    <type>amp</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/amps</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.alfresco.aos-module</groupId>
                                    <artifactId>alfresco-aos-module</artifactId>
                                    <version>${alfresco.aos-module.version}</version>
                                    <type>amp</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/amps</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.alfresco.integrations</groupId>
                                    <artifactId>alfresco-googledocs-repo</artifactId>
                                    <version>${alfresco.googledocs.version}</version>
                                    <type>amp</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/amps</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>io.fabric8</groupId>
                <artifactId>fabric8-maven-plugin</artifactId>
                <version>${dependency.fabric8.version}</version>
                <configuration>
                    <images>
                        <image>
                            <name>${image.name}:${image.tag}</name>
                            <registry>${image.registry}</registry>
                            <build>
                                <dockerFileDir>${project.basedir}/</dockerFileDir>
                            </build>
                        </image>
                    </images>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>communityDocker</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>fabric8-maven-plugin</artifactId>
                        <version>${dependency.fabric8.version}</version>
                        <executions>
                            <execution>
                                <id>build-image</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>internal</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>fabric8-maven-plugin</artifactId>
                        <version>${dependency.fabric8.version}</version>
                        <executions>
                            <execution>
                                <id>build-push-image</id>
                                <phase>install</phase>
                                <goals>
                                    <goal>build</goal>
                                    <goal>push</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>fabric8-maven-plugin</artifactId>
                        <version>${dependency.fabric8.version}</version>
                        <configuration>
                            <images>
                                <image>
                                    <name>${image.name}:${project.version}</name>
                                    <registry>${image.registry}</registry>
                                    <build>
                                        <dockerFileDir>${project.basedir}/</dockerFileDir>
                                    </build>
                                </image>
                                <!-- Commented out push to dockerhub.
                                <image>
                                    <name>${image.name}:${project.version}</name>
                                    <registry>${public.image.registry}</registry>
                                    <build>
                                        <dockerFileDir>${project.basedir}/</dockerFileDir>
                                    </build>
                                </image>
                                -->
                            </images>
                        </configuration>
                        <executions>
                            <execution>
                                <id>build-push-image</id>
                                <phase>deploy</phase>
                                <goals>
                                    <goal>build</goal>
                                    <goal>push</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>


</project>