<?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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.walmartlabs.concord</groupId>
        <artifactId>parent</artifactId>
        <version>1.101.0</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <groupId>com.walmartlabs.concord.docker</groupId>
    <artifactId>parent</artifactId>
    <packaging>pom</packaging>

    <modules>
        <module>base</module>
        <module>ansible</module>
        <module>agent</module>
        <module>server</module>
    </modules>

    <properties>
        <docker.skip>true</docker.skip>
        <docker.maintainer>ibodrov@gmail.com</docker.maintainer>
        <docker.namespace>walmartlabs</docker.namespace>
        <concord.baseDir>/opt/concord</concord.baseDir>
        <image.platforms>linux/amd64</image.platforms>
    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>exec-maven-plugin</artifactId>
                    <executions>
                        <execution>
                            <id>docker-build</id>
                            <goals>
                                <goal>exec</goal>
                            </goals>
                            <configuration>
                                <skip>${docker.skip}</skip>
                                <executable>docker</executable>
                                <workingDirectory>${project.basedir}</workingDirectory>
                                <arguments>
                                    <argument>buildx</argument>
                                    <argument>build</argument>

                                    <argument>-t</argument>
                                    <argument>${docker.tagbase}:latest</argument>
                                    <argument>-t</argument>
                                    <argument>${docker.tagbase}:${project.version}</argument>

                                    <argument>-f</argument>
                                    <argument>${docker.file}</argument>

                                    <argument>--build-arg=docker_namespace=${docker.namespace}</argument>
                                    <argument>--build-arg=concord_version=${project.version}</argument>
                                    <argument>--build-arg=jdk_version=${jdk.version}</argument>

                                    <argument>--network</argument>
                                    <argument>host</argument>

                                    <argument>--platform=${image.platforms}</argument>

                                    <argument>.</argument>
                                </arguments>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>docker</id>
            <properties>
                <docker.skip>false</docker.skip>
            </properties>
        </profile>
        <profile>
            <id>jdk11-aarch64</id>
            <properties>
                <image.platforms>linux/aarch64</image.platforms>
            </properties>
        </profile>
        <profile>
            <id>jdk17-aarch64</id>
            <properties>
                <image.platforms>linux/aarch64</image.platforms>
            </properties>
        </profile>
    </profiles>
</project>
