<!--

     Copyright 2005-2015 Red Hat, Inc.

     Red Hat licenses this file to you 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 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>io.fabric8.devops.apps</groupId>
    <artifactId>fabric8-devops</artifactId>
    <version>2.2.210</version>
  </parent>

  <artifactId>kibana</artifactId>

  <name>Kibana</name>
  <description>
    Awesome front-end for Elasticsearch
  </description>

  <properties>
    <docker.image>${fabric8.dockerUser}kibana4:v4.5.1</docker.image>
    <docker.port.container.http>5601</docker.port.container.http>
    <docker.port.container.jolokia />

    <fabric8.env.ELASTICSEARCH_URL>http://elasticsearch:9200</fabric8.env.ELASTICSEARCH_URL>

    <fabric8.service.port>80</fabric8.service.port>
    <fabric8.service.containerPort>5601</fabric8.service.containerPort>
    <fabric8.service.type>LoadBalancer</fabric8.service.type>

    <fabric8.label.project>kibana</fabric8.label.project>
    <fabric8.label.provider>fabric8</fabric8.label.provider>

    <fabric8.livenessProbe.port>5601</fabric8.livenessProbe.port>
    <fabric8.livenessProbe.initialDelaySeconds>60</fabric8.livenessProbe.initialDelaySeconds>
    <fabric8.readinessProbe.httpGet.port>5601</fabric8.readinessProbe.httpGet.port>
    <fabric8.readinessProbe.httpGet.path>/</fabric8.readinessProbe.httpGet.path>
    <fabric8.readinessProbe.initialDelaySeconds>5</fabric8.readinessProbe.initialDelaySeconds>

    <elasticsearch.url>http://elasticsearch.vagrant.f8/</elasticsearch.url>

    <docker.image.version>${project.version}</docker.image.version>
  </properties>

  <build>
    <resources>
      <resource>
        <directory>src/main/fabric8</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <fork>true</fork>
          <compilerArgs>
            <arg>-J-Ddocker.image.version=${docker.image.version}</arg>
          </compilerArgs>
        </configuration>
      </plugin>
      <plugin>
        <groupId>io.fabric8</groupId>
        <artifactId>docker-maven-plugin</artifactId>
        <version>${docker.maven.plugin.version}</version>
        <configuration>
          <image>${fabric8.dockerUser}kibana-config:${docker.image.version}</image>
          <images>
            <image>
              <name>${fabric8.dockerUser}kibana-config:${docker.image.version}</name>
              <build>
                <from>docker.io/centos:7</from>
                <nocache>true</nocache>
                <assembly>
                  <basedir>/</basedir>
                  <mode>tar</mode>
                  <inline xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
                    <id>kibana-config</id>
                    <fileSets>
                      <fileSet>
                        <directory>${basedir}/src/main/resources</directory>
                        <outputDirectory>/</outputDirectory>
                        <includes>
                          <include>**/*</include>
                        </includes>
                        <fileMode>0755</fileMode>
                      </fileSet>
                    </fileSets>
                  </inline>
                </assembly>
                <cmd>
                  <shell>/put-config.sh</shell>
                </cmd>
              </build>
            </image>
          </images>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.2.1</version>
        <configuration>
          <mainClass>io.fabric8.apps.kibana.ExportKibanaObjects</mainClass>
          <includePluginDependencies>false</includePluginDependencies>
          <classpathScope>test</classpathScope>
          <arguments>
            <argument>${elasticsearch.url}</argument>
            <argument>${basedir}/src/main/resources/kibana-objects</argument>
          </arguments>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <dependencies>
    <dependency>
      <groupId>io.fabric8</groupId>
      <artifactId>kubernetes-generator</artifactId>
    </dependency>

    <!-- testing -->
    <dependency>
      <groupId>org.jboss.arquillian.junit</groupId>
      <artifactId>arquillian-junit-container</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>io.fabric8</groupId>
      <artifactId>fabric8-arquillian</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>io.fabric8</groupId>
      <artifactId>kubernetes-assertions</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>io.fabric8.devops.apps</groupId>
      <artifactId>collector-utils</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>docker-build</id>
      <build>
        <plugins>
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>${docker.maven.plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>build</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>docker-push</id>
      <build>
        <plugins>
          <plugin>
            <groupId>io.fabric8</groupId>
            <artifactId>docker-maven-plugin</artifactId>
            <version>${docker.maven.plugin.version}</version>
            <executions>
              <execution>
                <goals>
                  <goal>build</goal>
                  <goal>push</goal>
                </goals>
                <phase>package</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- generates a unique timestamped image each build for easier development on snapshots -->
    <profile>
      <id>docker-snapshot</id>
      <properties>
        <docker.image.version>${maven.build.timestamp}</docker.image.version>
        <maven.build.timestamp.format>yyyy-MM-dd-HH-mm-ss</maven.build.timestamp.format>

        <!-- lets use verbose logging -->
        <docker.verbose>true</docker.verbose>
      </properties>
    </profile>
  </profiles>
</project>
