Cleanup PRH Docker image 98/76198/1
authorPiotr Bocheński <piotr.bochenski@nokia.com>
Wed, 23 Jan 2019 14:01:00 +0000 (15:01 +0100)
committerPiotr Bocheński <piotr.bochenski@nokia.com>
Wed, 23 Jan 2019 14:01:00 +0000 (15:01 +0100)
Put all external libs as separated image layer.

Change-Id: I06b0cd0a7eaf59cbb62463c715d5ae59f587e1ac
Issue-ID: DCAEGEN2-1030
Signed-off-by: Piotr Bocheński <piotr.bochenski@nokia.com>
README.md
prh-app-server/pom.xml

index 1592505..efbc89b 100644 (file)
--- a/README.md
+++ b/README.md
@@ -36,13 +36,11 @@ dcae-services
 
 ### Maven Children Artifacts:
 1. prh-app-server: Pnf Registration Handler (PRH) server
-2. prh-aai-client: Contains implementation of AAI client
-3. prh-dmaap-client: Contains implementation of DmaaP client
-4. prh-commons: Common code for whole prh modules
+2. prh-commons: Common code for whole prh modules
 
 
 ## License
 
-Copyright (C) 2018 NOKIA Intellectual Property. All rights reserved.
+Copyright (C) 2018-2019 NOKIA Intellectual Property. All rights reserved.
 [License](http://www.apache.org/licenses/LICENSE-2.0)
 
index ab0d8d2..405a97f 100644 (file)
   <packaging>jar</packaging>
 
   <properties>
-    <docker.image.name>onap/${project.groupId}.${project.artifactId}</docker.image.name>
     <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
+
+    <prh.main.class>org.onap.dcaegen2.services.prh.MainApp</prh.main.class>
+    <dependency.dir.name>libs</dependency.dir.name>
+    <dependency.dir.location>${project.build.directory}/${dependency.dir.name}</dependency.dir.location>
+    <docker.artifact.dir>/opt</docker.artifact.dir>
+    <docker.image.name>onap/${project.groupId}.${project.artifactId}</docker.image.name>
   </properties>
 
   <build>
 
     <plugins>
       <plugin>
-        <groupId>org.springframework.boot</groupId>
-        <artifactId>spring-boot-maven-plugin</artifactId>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-jar-plugin</artifactId>
+        <version>3.0.2</version>
+        <configuration>
+          <archive>
+            <manifestEntries>
+              <Main-Class>${prh.main.class}</Main-Class>
+              <Build-Time>${maven.build.timestamp}</Build-Time>
+            </manifestEntries>
+          </archive>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
         <configuration>
-          <finalName>${project.artifactId}</finalName>
-          <mainClass>org.onap.dcaegen2.services.prh.MainApp</mainClass>
+          <outputDirectory>${dependency.dir.location}</outputDirectory>
+          <includeScope>runtime</includeScope>
+          <silent>true</silent>
         </configuration>
+        <executions>
+          <execution>
+            <id>copy-external-dependencies</id>
+            <phase>package</phase>
+            <goals>
+              <goal>copy-dependencies</goal>
+            </goals>
+          </execution>
+        </executions>
       </plugin>
       <plugin>
         <groupId>com.spotify</groupId>
             <tag>latest</tag>
           </imageTags>
           <baseImage>openjdk:8-jre-alpine</baseImage>
+          <exposes>
+            <expose>8100</expose>
+            <expose>8433</expose>
+          </exposes>
+          <cmd>java -cp ${docker.artifact.dir}/${dependency.dir.name}/*:${docker.artifact.dir}/${project.build.finalName}.jar ${prh.main.class}</cmd>
           <resources>
+            <resource>
+              <directory>${dependency.dir.location}</directory>
+              <targetPath>${docker.artifact.dir}/${dependency.dir.name}</targetPath>
+            </resource>
             <resource>
               <directory>${project.build.directory}</directory>
-              <include>${project.artifactId}.jar</include>
-              <targetPath>/opt</targetPath>
+              <include>${project.build.finalName}.jar</include>
+              <targetPath>${docker.artifact.dir}</targetPath>
             </resource>
           </resources>
-          <exposes>
-            <expose>8100</expose>
-            <expose>8433</expose>
-          </exposes>
-          <cmd>["java", "-jar", "/opt/${project.artifactId}.jar"]</cmd>
         </configuration>
         <executions>
           <execution>