Docker file: networkDiscovery serviceDecomposition 87/60787/3
authorMohammadreza Pasandideh <mohammadreza.pasandideh@amdocs.com>
Wed, 15 Aug 2018 19:41:22 +0000 (15:41 -0400)
committerMohammadreza Pasandideh <mohammadreza.pasandideh@amdocs.com>
Thu, 16 Aug 2018 17:45:55 +0000 (13:45 -0400)
Issue-ID: LOG-397 SDNC-317

Change-Id: I80171ad4332e70872e5d3d8c42625f8669aa4d99
Signed-off-by: Mohammadreza Pasandideh <mohammadreza.pasandideh@amdocs.com>
pomba/network-discovery/pom.xml
pomba/network-discovery/src/main/docker/Dockerfile [new file with mode: 0644]
pomba/network-discovery/src/main/docker/startService.sh [new file with mode: 0644]
pomba/service-decomposition/pom.xml
pomba/service-decomposition/src/main/docker/Dockerfile [new file with mode: 0644]
pomba/service-decomposition/src/main/docker/startService.sh [new file with mode: 0644]

index 44e919b..8f0d725 100644 (file)
@@ -32,6 +32,9 @@ limitations under the License.
     <properties>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <swagger.directory>${project.build.directory}/generated-resources/swagger</swagger.directory>
+        <!--docker -->
+        <docker.tag>${project.version}-${timestamp}</docker.tag>
+        <docker.latest.tag>${project.version}-latest</docker.latest.tag>
     </properties>
 
     <dependencyManagement>
@@ -134,47 +137,8 @@ limitations under the License.
     </dependencies>
 
     <build>
-        <finalName>network-discovery</finalName>
+        <finalName>${project.artifactId}</finalName>
         <plugins>
-            <plugin>
-                <groupId>com.github.kongchen</groupId>
-                <artifactId>swagger-maven-plugin</artifactId>
-                <version>3.1.7</version>
-                <configuration>
-                    <apiSources>
-                        <apiSource>
-                            <locations>
-                                <location>org.onap.sdnc.apps.pomba.networkdiscovery.service.rs</location>
-                            </locations>
-                            <basePath>/network-discovery</basePath>
-                            <info>
-                                <title>Network Discovery API</title>
-                                <version>${project.version}</version>
-                                <termsOfService>http://onap.org</termsOfService>
-                                <contact>
-                                    <name>Sharon Chisholm</name>
-                                    <email>sharon.chisholm@amdocs.com</email>
-                                </contact>
-                            </info>
-                            <securityDefinitions>
-                                <securityDefinition>
-                                    <name>basicAuth</name>
-                                    <type>basic</type>
-                                </securityDefinition>
-                            </securityDefinitions>
-                            <swaggerDirectory>${swagger.directory}</swaggerDirectory>
-                        </apiSource>
-                    </apiSources>
-                </configuration>
-                <executions>
-                    <execution>
-                        <phase>compile</phase>
-                        <goals>
-                            <goal>generate</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
             <plugin>
                 <artifactId>maven-resources-plugin</artifactId>
                 <version>3.1.0</version>
@@ -210,8 +174,7 @@ limitations under the License.
                 </executions>
             </plugin>
         </plugins>
-        <!-- mention the logback.xml location through system property or environment variable to edit logback.xml at run
-            time -->
+        <!-- mention the logback.xml location through system property or environment variable to edit logback.xml at run time -->
         <resources>
             <resource>
                 <directory>src/main/resources</directory>
@@ -222,4 +185,192 @@ limitations under the License.
             </resource>
         </resources>
     </build>
+
+    <profiles>
+        <profile>
+            <id>docker</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>io.fabric8</groupId>
+                        <artifactId>docker-maven-plugin</artifactId>
+                        <version>0.19.1</version>
+                        <configuration>
+                            <verbose>true</verbose>
+                            <apiVersion>1.23</apiVersion>
+                            <images>
+                                <image>
+                                    <name>onap/${project.artifactId}</name>
+                                    <alias>${project.artifactId}</alias>
+                                    <build>
+                                        <cleanup>try</cleanup>
+                                        <dockerFileDir>${project.basedir}/target/docker-stage</dockerFileDir>
+                                        <tags>
+                                            <tag>${docker.snapshot.tag}</tag>
+                                            <tag>${docker.latest.tag}</tag>
+                                        </tags>
+                                    </build>
+                                </image>
+                            </images>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>generate-images</id>
+                                <phase>generate-sources</phase>
+                                <goals>
+                                    <goal>build</goal>
+                                </goals>
+                            </execution>
+                            <execution>
+                                <id>push-images</id>
+                                <phase>deploy</phase>
+                                <goals>
+                                    <goal>build</goal>
+                                    <goal>push</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <groupId>com.github.kongchen</groupId>
+                        <artifactId>swagger-maven-plugin</artifactId>
+                        <version>3.1.7</version>
+                        <configuration>
+                            <apiSources>
+                                <apiSource>
+                                    <locations>
+                                        <location>org.onap.sdnc.apps.pomba.networkdiscovery.service.rs</location>
+                                    </locations>
+                                    <basePath>/network-discovery</basePath>
+                                    <info>
+                                        <title>Network Discovery API</title>
+                                        <version>${project.version}</version>
+                                        <termsOfService>http://onap.org</termsOfService>
+                                    </info>
+                                    <securityDefinitions>
+                                        <securityDefinition>
+                                            <name>basicAuth</name>
+                                            <type>basic</type>
+                                        </securityDefinition>
+                                    </securityDefinitions>
+                                    <swaggerDirectory>${swagger.directory}</swaggerDirectory>
+                                </apiSource>
+                            </apiSources>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <phase>compile</phase>
+                                <goals>
+                                    <goal>generate</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-resources-plugin</artifactId>
+                        <version>2.6</version>
+                        <executions>
+                            <execution>
+                                <id>copy-dockerfile</id>
+                                <goals>
+                                    <goal>copy-resources</goal>
+                                </goals><!-- here the phase you need -->
+                                <phase>package</phase>
+                                <configuration>
+                                    <outputDirectory>${project.basedir}/target/docker-stage</outputDirectory>
+                                    <resources>
+                                        <resource>
+                                            <directory>src/main/docker</directory>
+                                            <includes>
+                                                <include>Dockerfile</include>
+                                            </includes>
+                                            <filtering>true</filtering>
+                                        </resource>
+                                    </resources>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>copy-properties</id>
+                                <goals>
+                                    <goal>copy-resources</goal>
+                                </goals>
+                                <phase>package</phase>
+                                <configuration>
+                                    <outputDirectory>${project.basedir}/target/docker-stage/config</outputDirectory>
+                                    <resources>
+                                        <resource>
+                                            <directory>config</directory>
+                                            <includes>
+                                                <include>*.properties</include>
+                                                <include>*.xml</include>
+                                            </includes>
+                                            <filtering>false</filtering>
+                                        </resource>
+                                    </resources>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>copy-certificate</id>
+                                <goals>
+                                    <goal>copy-resources</goal>
+                                </goals>
+                                <phase>package</phase>
+                                <configuration>
+                                    <outputDirectory>${project.basedir}/target/docker-stage/config/auth</outputDirectory>
+                                    <resources>
+                                        <resource>
+                                            <directory>auth</directory>
+                                            <includes>
+                                                <include>*.p12</include>
+                                            </includes>
+                                            <filtering>false</filtering>
+                                        </resource>
+                                    </resources>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>copy-script</id>
+                                <goals>
+                                    <goal>copy-resources</goal>
+                                </goals>
+                                <phase>package</phase>
+                                <configuration>
+                                    <outputDirectory>${project.basedir}/target/docker-stage/</outputDirectory>
+                                    <resources>
+                                        <resource>
+                                            <directory>src/main/docker</directory>
+                                            <includes>
+                                                <include>*.sh</include>
+                                            </includes>
+                                            <filtering>false</filtering>
+                                        </resource>
+                                    </resources>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>copy-jar</id>
+                                <goals>
+                                    <goal>copy-resources</goal>
+                                </goals>
+                                <phase>package</phase>
+                                <configuration>
+                                    <outputDirectory>${project.basedir}/target/docker-stage/</outputDirectory>
+                                    <resources>
+                                        <resource>
+                                            <directory>target</directory>
+                                            <includes>
+                                                <include>*.jar</include>
+                                            </includes>
+                                            <filtering>false</filtering>
+                                        </resource>
+                                    </resources>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
 </project>
diff --git a/pomba/network-discovery/src/main/docker/Dockerfile b/pomba/network-discovery/src/main/docker/Dockerfile
new file mode 100644 (file)
index 0000000..a7f5782
--- /dev/null
@@ -0,0 +1,22 @@
+FROM anapsix/alpine-java:jre8
+
+ARG MICROSERVICE_HOME=/opt/app/
+
+# Build up the deployment folder structure
+RUN mkdir -p $MICROSERVICE_HOME
+RUN mkdir -p $MICROSERVICE_HOME/config/
+RUN mkdir -p $MICROSERVICE_HOME/config/auth/
+RUN mkdir -p $MICROSERVICE_HOME/lib/
+RUN mkdir -p $MICROSERVICE_HOME/bin/
+
+ADD pomba-network-discovery.jar $MICROSERVICE_HOME/lib/
+ADD startService.sh $MICROSERVICE_HOME/bin/
+COPY config/ $MICROSERVICE_HOME/config/
+COPY config/auth/ $MICROSERVICE_HOME/config/auth/
+
+RUN chmod 755 $MICROSERVICE_HOME/config/*
+RUN chmod 755 $MICROSERVICE_HOME/config/auth/*
+RUN chmod 755 $MICROSERVICE_HOME/lib/*
+RUN chmod 755 $MICROSERVICE_HOME/bin/*
+
+CMD ["/opt/app/bin/startService.sh"]
\ No newline at end of file
diff --git a/pomba/network-discovery/src/main/docker/startService.sh b/pomba/network-discovery/src/main/docker/startService.sh
new file mode 100644 (file)
index 0000000..2169c4d
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+cd /opt/app
+if [ -z "${java_runtime_arguments}" ]; then
+    java -Dlogging.config=config/logback.xml -Xms128m -Xmx512m -jar /opt/app/lib/pomba-network-discovery.jar
+else
+    java -Dlogging.config=config/logback.xml $java_runtime_arguments -jar /opt/app/lib/pomba-network-discovery.jar
+fi
\ No newline at end of file
index 6252246..39ebf3d 100644 (file)
@@ -1,4 +1,21 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!--
+============LICENSE_START===================================================
+Copyright (c) 2018 Amdocs
+============================================================================
+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.
+============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">
     <modelVersion>4.0.0</modelVersion>
@@ -16,6 +33,9 @@
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <swagger.directory>${project.build.directory}/generated-resources/swagger</swagger.directory>
         <serviceArtifactName>service-decomposition</serviceArtifactName>
+        <!--docker -->
+        <docker.tag>${project.version}-${timestamp}</docker.tag>
+        <docker.latest.tag>${project.version}-latest</docker.latest.tag>
     </properties>
 
     <dependencyManagement>
     </dependencies>
 
     <build>
-        <finalName>service-decomposition</finalName>
+        <finalName>${project.artifactId}</finalName>
         <plugins>
-            <plugin>
-                <groupId>com.github.kongchen</groupId>
-                <artifactId>swagger-maven-plugin</artifactId>
-                <version>3.1.3</version>
-                <configuration>
-                    <apiSources>
-                        <apiSource>
-                            <locations>org.onap.sdnc.apps.pomba.servicedecomposition.service.rs</locations>
-                            <basePath>/service-decomposition</basePath>
-                            <info>
-                                <title>${project.artifactId} Service</title>
-                                <version>${project.version}</version>
-                            </info>
-                            <securityDefinitions>
-                                <securityDefinition>
-                                    <name>basicAuth</name>
-                                    <type>basic</type>
-                                </securityDefinition>
-                            </securityDefinitions>
-                            <swaggerDirectory>${swagger.directory}</swaggerDirectory>
-                        </apiSource>
-                    </apiSources>
-                </configuration>
-                <executions>
-                    <execution>
-                        <phase>compile</phase>
-                        <goals>
-                            <goal>generate</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
             <plugin>
                 <artifactId>maven-resources-plugin</artifactId>
                 <version>3.1.0</version>
                 </executions>
             </plugin>
         </plugins>
+        <!-- mention the logback.xml location through system property or environment variable to edit logback.xml at run time -->
+        <resources>
+            <resource>
+                <directory>src/main/resources</directory>
+                <filtering>true</filtering>
+                <includes>
+                    <include>**/*</include>
+                </includes>
+            </resource>
+        </resources>
     </build>
+
+    <profiles>
+        <profile>
+            <id>docker</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>io.fabric8</groupId>
+                        <artifactId>docker-maven-plugin</artifactId>
+                        <version>0.19.1</version>
+                        <configuration>
+                            <verbose>true</verbose>
+                            <apiVersion>1.23</apiVersion>
+                            <images>
+                                <image>
+                                    <name>onap/${project.artifactId}</name>
+                                    <alias>${project.artifactId}</alias>
+                                    <build>
+                                        <cleanup>try</cleanup>
+                                        <dockerFileDir>${project.basedir}/target/docker-stage</dockerFileDir>
+                                        <tags>
+                                            <tag>${docker.snapshot.tag}</tag>
+                                            <tag>${docker.latest.tag}</tag>
+                                        </tags>
+                                    </build>
+                                </image>
+                            </images>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>generate-images</id>
+                                <phase>generate-sources</phase>
+                                <goals>
+                                    <goal>build</goal>
+                                </goals>
+                            </execution>
+                            <execution>
+                                <id>push-images</id>
+                                <phase>deploy</phase>
+                                <goals>
+                                    <goal>build</goal>
+                                    <goal>push</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <groupId>com.github.kongchen</groupId>
+                        <artifactId>swagger-maven-plugin</artifactId>
+                        <version>3.1.3</version>
+                        <configuration>
+                            <apiSources>
+                                <apiSource>
+                                    <locations>org.onap.sdnc.apps.pomba.servicedecomposition.service.rs</locations>
+                                    <basePath>/service-decomposition</basePath>
+                                    <info>
+                                        <title>Service Decomposition API</title>
+                                        <version>${project.version}</version>
+                                        <termsOfService>http://onap.org</termsOfService>
+                                    </info>
+                                    <securityDefinitions>
+                                        <securityDefinition>
+                                            <name>basicAuth</name>
+                                            <type>basic</type>
+                                        </securityDefinition>
+                                    </securityDefinitions>
+                                    <swaggerDirectory>${swagger.directory}</swaggerDirectory>
+                                </apiSource>
+                            </apiSources>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <phase>compile</phase>
+                                <goals>
+                                    <goal>generate</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                    <plugin>
+                        <artifactId>maven-resources-plugin</artifactId>
+                        <version>2.6</version>
+                        <executions>
+                            <execution>
+                                <id>copy-dockerfile</id>
+                                <goals>
+                                    <goal>copy-resources</goal>
+                                </goals><!-- here the phase you need -->
+                                <phase>package</phase>
+                                <configuration>
+                                    <outputDirectory>${project.basedir}/target/docker-stage</outputDirectory>
+                                    <resources>
+                                        <resource>
+                                            <directory>src/main/docker</directory>
+                                            <includes>
+                                                <include>Dockerfile</include>
+                                            </includes>
+                                            <filtering>true</filtering>
+                                        </resource>
+                                    </resources>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>copy-properties</id>
+                                <goals>
+                                    <goal>copy-resources</goal>
+                                </goals>
+                                <phase>package</phase>
+                                <configuration>
+                                    <outputDirectory>${project.basedir}/target/docker-stage/config</outputDirectory>
+                                    <resources>
+                                        <resource>
+                                            <directory>config</directory>
+                                            <includes>
+                                                <include>*.properties</include>
+                                                <include>*.xml</include>
+                                            </includes>
+                                            <filtering>false</filtering>
+                                        </resource>
+                                    </resources>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>copy-script</id>
+                                <goals>
+                                    <goal>copy-resources</goal>
+                                </goals>
+                                <phase>package</phase>
+                                <configuration>
+                                    <outputDirectory>${project.basedir}/target/docker-stage/</outputDirectory>
+                                    <resources>
+                                        <resource>
+                                            <directory>src/main/docker</directory>
+                                            <includes>
+                                                <include>*.sh</include>
+                                            </includes>
+                                            <filtering>false</filtering>
+                                        </resource>
+                                    </resources>
+                                </configuration>
+                            </execution>
+                            <execution>
+                                <id>copy-jar</id>
+                                <goals>
+                                    <goal>copy-resources</goal>
+                                </goals>
+                                <phase>package</phase>
+                                <configuration>
+                                    <outputDirectory>${project.basedir}/target/docker-stage/</outputDirectory>
+                                    <resources>
+                                        <resource>
+                                            <directory>target</directory>
+                                            <includes>
+                                                <include>*.jar</include>
+                                            </includes>
+                                            <filtering>false</filtering>
+                                        </resource>
+                                    </resources>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
 </project>
diff --git a/pomba/service-decomposition/src/main/docker/Dockerfile b/pomba/service-decomposition/src/main/docker/Dockerfile
new file mode 100644 (file)
index 0000000..55a7b68
--- /dev/null
@@ -0,0 +1,19 @@
+FROM anapsix/alpine-java:jre8
+
+ARG MICROSERVICE_HOME=/opt/app/
+
+# Build up the deployment folder structure
+RUN mkdir -p $MICROSERVICE_HOME
+RUN mkdir -p $MICROSERVICE_HOME/config/
+RUN mkdir -p $MICROSERVICE_HOME/lib/
+RUN mkdir -p $MICROSERVICE_HOME/bin/
+
+ADD pomba-service-decomposition.jar $MICROSERVICE_HOME/lib/
+ADD startService.sh $MICROSERVICE_HOME/bin/
+COPY config/ $MICROSERVICE_HOME/config/
+
+RUN chmod 755 $MICROSERVICE_HOME/config/*
+RUN chmod 755 $MICROSERVICE_HOME/lib/*
+RUN chmod 755 $MICROSERVICE_HOME/bin/*
+
+CMD ["/opt/app/bin/startService.sh"]
\ No newline at end of file
diff --git a/pomba/service-decomposition/src/main/docker/startService.sh b/pomba/service-decomposition/src/main/docker/startService.sh
new file mode 100644 (file)
index 0000000..5efbe79
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+cd /opt/app
+if [ -z "${java_runtime_arguments}" ]; then
+    java -Dlogging.config=config/logback.xml -Xms128m -Xmx512m -jar /opt/app/lib/pomba-service-decomposition.jar
+else
+    java -Dlogging.config=config/logback.xml $java_runtime_arguments -jar /opt/app/lib/pomba-service-decomposition.jar
+fi
\ No newline at end of file