<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (C) 2006-2026 Talend Inc. - www.talend.com
   Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.talend.sdk.component</groupId>
    <artifactId>images</artifactId>
    <version>1.93.0</version>
  </parent>

  <artifactId>component-server-image</artifactId>

  <name>Component Runtime :: Images :: Server</name>

  <properties>
    <talend.build.name>${talend.build.name.base}.server.image</talend.build.name>
    <!-- mandatory module docker properties -->
    <docker.talend.app.name>component-server</docker.talend.app.name>
    <docker.talend.app.product>component-kit</docker.talend.app.product>
    <docker.talend.app.description>Talend Component Kit backend server</docker.talend.app.description>
    <!-- custom component-server parameters -->
    <docker.talend.image.tag>${project.version}-${maven.build.timestamp}</docker.talend.image.tag>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>component-server</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>jakarta.activation</groupId>
      <artifactId>jakarta.activation-api</artifactId>
      <version>1.2.2</version>
    </dependency>

    <!-- beam support -->
    <dependency>
      <groupId>org.talend.sdk.component</groupId>
      <artifactId>component-runtime-beam</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.beam</groupId>
      <artifactId>beam-sdks-java-core</artifactId>
      <exclusions>
        <exclusion>
          <groupId>com.google.errorprone</groupId>
          <artifactId>error_prone_annotations</artifactId>
        </exclusion>
        <exclusion>
          <!-- too much CVE for now and no version with a fix -->
          <groupId>org.codehaus.jackson</groupId>
          <artifactId>jackson-mapper-asl</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- for prod/monitoring -->
    <dependency>
      <groupId>org.apache.geronimo</groupId>
      <artifactId>docker-configsource</artifactId>
      <version>${geronimo-microprofile.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.geronimo</groupId>
      <artifactId>secured-string-converter</artifactId>
      <version>${geronimo-microprofile.version}</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.microprofile.metrics</groupId>
      <artifactId>microprofile-metrics-api</artifactId>
      <version>${microprofile-metrics-api.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.osgi</groupId>
          <artifactId>org.osgi.annotation.versioning</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>org.apache.geronimo</groupId>
      <artifactId>geronimo-metrics</artifactId>
      <version>${geronimo-metrics.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.geronimo</groupId>
      <artifactId>geronimo-metrics-tomcat</artifactId>
      <version>${geronimo-metrics.version}</version>
    </dependency>
    <dependency>
      <groupId>org.apache.geronimo</groupId>
      <artifactId>geronimo-metrics-sigar</artifactId>
      <version>${geronimo-metrics.version}</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/meecrowave.properties</exclude>
            <exclude>**/log4j*.xml</exclude>
            <exclude>docker/**</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-resources</id>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <phase>prepare-package</phase>
            <configuration>
              <outputDirectory>${docker.image.extra.files}/opt/talend/component-kit/conf</outputDirectory>
              <resources>
                <resource>
                  <directory>${project.basedir}/src/main/resources</directory>
                  <filtering>false</filtering>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>unpack-sigar</id>
            <goals>
              <goal>unpack</goal>
            </goals>
            <phase>prepare-package</phase>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.fusesource</groupId>
                  <artifactId>sigar</artifactId>
                  <version>1.6.4</version>
                  <classifier>native</classifier>
                  <type>jar</type>
                  <outputDirectory>${docker.image.extra.files}/opt/talend/component-kit/sigar</outputDirectory>
                  <includes>**/libsigar-amd64-linux-1.6.4.so</includes>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>com.google.cloud.tools</groupId>
        <artifactId>jib-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>build</id>
            <phase>none</phase>
            <configuration>
              <extraDirectories>
                <paths>
                  <path>${docker.image.extra.files}</path>
                  <path>src/main/jib</path>
                </paths>
                <permissions>
                  <permission>
                    <file>/entrypoint.sh</file>
                    <mode>755</mode>
                  </permission>
                </permissions>
              </extraDirectories>
              <container>
                <user>talend:talend</user>
                <entrypoint>/entrypoint.sh</entrypoint>
                <mainClass>org.apache.meecrowave.runner.Cli</mainClass>
                <args>
                  <arg>java</arg>
                  <arg>org.apache.meecrowave.runner.Cli</arg>
                </args>
                <expandClasspathDependencies>true</expandClasspathDependencies>
                <extraClasspath>${docker.talend.dir.app}classes,${docker.talend.dir.app}custom/*,${docker.talend.dir.app}extensions/*,${docker.talend.dir.app}resources,${docker.talend.dir.base}classes,${docker.talend.dir.base}custom/*,${docker.talend.dir.base}extensions/*,${docker.talend.dir.base}resources</extraClasspath>
                <environment>
                  <MEECROWAVE_HOME>${docker.talend.dir.base}</MEECROWAVE_HOME>
                  <MEECROWAVE_BASE>${docker.talend.dir.base}</MEECROWAVE_BASE>
                  <MEECROWAVE_PID>${docker.talend.dir.app}conf/server.pid</MEECROWAVE_PID>
                  <MEECROWAVE-PROPERTIES>${docker.talend.dir.app}conf/meecrowave.properties</MEECROWAVE-PROPERTIES>
                  <JAVA_IO_TMPDIR>${docker.talend.dir.app}temp</JAVA_IO_TMPDIR>
                  <LD_LIBRARY_PATH>${docker.talend.dir.app}sigar</LD_LIBRARY_PATH>
                  <LOGGING_LAYOUT>JSON</LOGGING_LAYOUT>
                  <LOG4J_CONFIGURATIONFILE>${docker.talend.dir.app}conf/log4j2-component-server-${LOGGING_LAYOUT}.xml</LOG4J_CONFIGURATIONFILE>
                  <TRACING_SAMPLING_RATE>1</TRACING_SAMPLING_RATE>
                  <TALEND_JDK_SERIAL_FILTER>oracle.sql.**;!*</TALEND_JDK_SERIAL_FILTER>
                  <TALEND_COMPONENT_SERVER_COMPONENT_REGISTRY>${docker.talend.dir.base}connectors/component-registry.properties</TALEND_COMPONENT_SERVER_COMPONENT_REGISTRY>
                  <TALEND_COMPONENT_SERVER_USER_EXTENSIONS_LOCATION>${docker.talend.dir.base}extensions</TALEND_COMPONENT_SERVER_USER_EXTENSIONS_LOCATION>
                  <TALEND_COMPONENT_SERVER_MAVEN_REPOSITORY>${docker.talend.dir.base}connectors</TALEND_COMPONENT_SERVER_MAVEN_REPOSITORY>
                  <TALEND_VAULT_CACHE_VAULT_DECRYPT_ENDPOINT>v1/tenants-keyrings/decrypt/{x-talend-tenant-id}</TALEND_VAULT_CACHE_VAULT_DECRYPT_ENDPOINT>
                  <CLASSPATH>${docker.talend.dir.app}classes,${docker.talend.dir.app}custom/*,${docker.talend.dir.app}extensions/*,${docker.talend.dir.app}resources,${docker.talend.dir.base}classes,${docker.talend.dir.base}custom/*,${docker.talend.dir.base}extensions/*,${docker.talend.dir.base}resources</CLASSPATH>
                  <JDK_JAVA_OPTIONS>--add-opens=java.base/java.lang.invoke=ALL-UNNAMED --add-opens=java.base/java.net=ALL-UNNAMED --add-opens=java.base/java.nio=ALL-UNNAMED --add-opens=java.base/sun.net=ALL-UNNAMED -Dlog4j.configurationFile=${docker.talend.dir.app}conf/log4j2-component-server-TEXT.xml</JDK_JAVA_OPTIONS>
                </environment>
                <labels>
                  <com.talend.docker.cmd>docker run -d -p ${docker.image.port}:${docker.image.port} ${docker.image.to}</com.talend.docker.cmd>
                  <com.talend.docker.healthcheck>curl --fail http://localhost:${docker.image.port}/api/v1/environment</com.talend.docker.healthcheck>
                  <com.talend.docker.params>_JAVA_OPTIONS=&lt;JVM options (system properties etc), ex: -Dtalend.component.server.component.registry=/path/to/component-registry.properties -Dtalend.component.server.maven.repository=/path/to/m2&gt;</com.talend.docker.params>
                </labels>
              </container>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>ci-build</id>
      <activation>
        <activeByDefault>false</activeByDefault>
        <property>
          <name>env.JENKINS_URL</name>
        </property>
      </activation>
      <dependencies>
        <!-- ecs logging layout -->
        <dependency>
          <groupId>org.talend.daikon</groupId>
          <artifactId>logging-event-layout</artifactId>
          <version>6.3.0</version>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
</project>
