<?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>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.3.3</version>
    </parent>

    <groupId>tk.antoine.roux</groupId>
    <artifactId>java-template</artifactId>
    <version>1.0.0-SNAPSHOT</version>
    <name>java-template</name>

    <properties>
        <java.version>21</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>

        <start-class>tk.antoine.roux.Main</start-class>
        <application.port>8080</application.port>

        <jib-maven-plugin.version>3.4.3</jib-maven-plugin.version>
        <micrometer-registry-prometheus.version>1.13.4</micrometer-registry-prometheus.version>
    </properties>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>io.micrometer</groupId>
                <artifactId>micrometer-registry-prometheus</artifactId>
                <version>${micrometer-registry-prometheus.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>io.micrometer</groupId>
            <artifactId>micrometer-registry-prometheus</artifactId>
        </dependency>

        <!-- test -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <version>${jib-maven-plugin.version}</version>
                <configuration>
                    <to>
                        <image>container.localdomain/${project.artifactId}</image>
                    </to>
                    <from>
                        <image>eclipse-temurin:21.0.1_12-jdk</image>
                        <platforms>
                            <platform>
                                <architecture>arm64</architecture>
                                <os>linux</os>
                            </platform>
                            <platform>
                                <architecture>amd64</architecture>
                                <os>linux</os>
                            </platform>
                        </platforms>
                    </from>
                    <container>
                        <environment>
                            <JAVA_OPTS>-Xms256m -Xmx256m -Xdebug</JAVA_OPTS>
                        </environment>
                        <mainClass>${start-class}</mainClass>
                        <entrypoint>
                            <arg>/__cacert_entrypoint.sh</arg>
                            <arg>sh</arg>
                            <arg>-c</arg>
                            <arg>java $JAVA_OPTS -cp \@/app/jib-classpath-file \@/app/jib-main-class-file</arg>
                        </entrypoint>
                        <labels>
                            <org.opencontainers.image.authors>antoinroux@hotmail.fr</org.opencontainers.image.authors>
                            <org.opencontainers.image.version>${project.version}</org.opencontainers.image.version>
                        </labels>
                        <ports>
                            <port>${application.port}</port>
                        </ports>
                        <environment>
                            <USE_SYSTEM_CA_CERTS>true</USE_SYSTEM_CA_CERTS>
                        </environment>
                    </container>
                    <extraDirectories>
                        <paths>
                            <path>
                                <from>src/main/resources</from>
                                <into>/certificates</into>
                                <includes>*.crt,**/*.crt</includes>
                            </path>
                        </paths>
                    </extraDirectories>
                    <allowInsecureRegistries>true</allowInsecureRegistries>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <distributionManagement>
        <repository>
            <id>gitea</id>
            <url>https://antoine-roux.tk/projects/api/packages/java-template/maven</url>
        </repository>
        <snapshotRepository>
            <id>gitea</id>
            <url>https://antoine-roux.tk/projects/api/packages/java-template/maven</url>
        </snapshotRepository>
    </distributionManagement>
</project>