Docker image creation 37/58337/2
authorfkrzywka <filip.krzywka@nokia.com>
Fri, 1 Jun 2018 10:45:22 +0000 (12:45 +0200)
committerPiotr Jaszczyk <piotr.jaszczyk@nokia.com>
Wed, 1 Aug 2018 06:42:19 +0000 (08:42 +0200)
Maven integration with docker build

Closes ONAP-226

Change-Id: I115ff9c13e1bf06a7594a174c7703bfea42f3641
Signed-off-by: fkrzywka <filip.krzywka@nokia.com>
Issue-ID: DCAEGEN2-601

hv-collector-main/Dockerfile [new file with mode: 0644]
hv-collector-main/pom.xml
pom.xml

diff --git a/hv-collector-main/Dockerfile b/hv-collector-main/Dockerfile
new file mode 100644 (file)
index 0000000..fd7ce21
--- /dev/null
@@ -0,0 +1,11 @@
+FROM openjdk:10-jre-slim
+LABEL maintainer="Nokia Wroclaw ONAP Team"
+
+EXPOSE 8081
+
+WORKDIR /opt/ves-hv-collector
+ENTRYPOINT ["java", "-cp", "*:", "org.onap.dcae.collectors.veshv.main.MainKt"]
+CMD ["--listen-port", "8081", "--config-url", ""]
+COPY target/libs/external/* ./
+COPY target/libs/internal/* ./
+COPY target/hv-collector-main-*.jar ./
\ No newline at end of file
index 9f02ed5..80d7233 100644 (file)
@@ -19,8 +19,8 @@
   ~ ============LICENSE_END=========================================================
   -->
 <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">
+         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>
 
     <licenses>
@@ -42,6 +42,7 @@
 
     <properties>
         <skipAnalysis>false</skipAnalysis>
+        <docker-image.name>ves-hv-collector</docker-image.name>
     </properties>
 
     <build>
                 <artifactId>maven-surefire-plugin</artifactId>
                 <groupId>org.apache.maven.plugins</groupId>
             </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-dependency-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <id>copy-internal-deps</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}/libs/internal</outputDirectory>
+                            <includeGroupIds>${project.parent.groupId}</includeGroupIds>
+                            <includeScope>runtime</includeScope>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>copy-external-deps</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>copy-dependencies</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${project.build.directory}/libs/external</outputDirectory>
+                            <excludeGroupIds>${project.parent.groupId}</excludeGroupIds>
+                            <includeScope>runtime</includeScope>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+            <plugin>
+                <groupId>io.fabric8</groupId>
+                <artifactId>docker-maven-plugin</artifactId>
+            </plugin>
         </plugins>
     </build>
 
diff --git a/pom.xml b/pom.xml
index 8ef993a..e02b1b5 100644 (file)
--- a/pom.xml
+++ b/pom.xml
     <failIfMissingUnitTests>true</failIfMissingUnitTests>
     <failIfMissingComponentTests>false</failIfMissingComponentTests>
     <skipAnalysis>true</skipAnalysis>
+
+    <skipDocker>true</skipDocker>
+    <docker-image.name>ves-hv-collector/${project.artifactId}</docker-image.name>
+    <docker-image.namespace>onap</docker-image.namespace>
   </properties>
 
 
             </dependency>
           </dependencies>
         </plugin>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-dependency-plugin</artifactId>
+          <version>3.1.1</version>
+        </plugin>
+        <plugin>
+          <groupId>io.fabric8</groupId>
+          <artifactId>docker-maven-plugin</artifactId>
+          <version>0.26.0</version>
+          <executions>
+            <execution>
+              <id>build-docker-image</id>
+              <phase>pre-integration-test</phase>
+              <goals>
+                <goal>build</goal>
+              </goals>
+            </execution>
+          </executions>
+          <configuration>
+            <skip>${skipDocker}</skip>
+            <verbose>true</verbose>
+            <imagePullPolicy>IfNotPresent</imagePullPolicy>
+            <images>
+              <image>
+                <alias>${project.artifactId}</alias>
+                <name>${docker-image.namespace}/${docker-image.name}</name>
+                <build>
+                  <dockerFileDir>${project.basedir}</dockerFileDir>
+                  <tags>
+                    <tag>${project.version}</tag>
+                  </tags>
+                </build>
+              </image>
+            </images>
+          </configuration>
+        </plugin>
       </plugins>
     </pluginManagement>
   </build>