Use io.fabric8:docker-maven-plugin to build and push docker images 04/89204/8
authorRashmi Pujar <rashmi.pujar@bell.ca>
Mon, 3 Jun 2019 21:14:45 +0000 (17:14 -0400)
committerRashmi Pujar <rashmi.pujar@bell.ca>
Tue, 11 Jun 2019 17:57:45 +0000 (13:57 -0400)
Addressed POLICY-1808 for drools-applications to fix the tag to be major.minor-SNAPSHOT-latest

Issue-ID: POLICY-969
Signed-off-by: Rashmi Pujar <rashmi.pujar@bell.ca>
Change-Id: I6c9ddec9a2e7a73ba68343eb98e0145ce811868e

controlloop/packages/apps-controlloop/pom.xml
controlloop/packages/apps-controlloop/src/assembly/zip.xml
controlloop/packages/docker-controlloop/pom.xml
controlloop/packages/docker-controlloop/src/main/assembly/assembly.xml [new file with mode: 0644]
controlloop/packages/docker-controlloop/src/main/docker/Dockerfile
controlloop/packages/docker-controlloop/src/main/resources/docker-entrypoint.sh [moved from controlloop/packages/docker-controlloop/src/main/docker/docker-entrypoint.sh with 100% similarity]
controlloop/packages/pom.xml

index 83c96c7..d288eb2 100644 (file)
@@ -3,6 +3,7 @@
   ONAP
   ================================================================================
   Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+  Modifications Copyright (C) 2019 Bell Canada.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   <build>
     <plugins>
       <plugin>
-       <artifactId>maven-assembly-plugin</artifactId>
-       <executions>
-         <execution>
-           <goals>
-             <goal>single</goal>
-           </goals>
-           <phase>package</phase>
-           <configuration>
-             <descriptors>
-               <descriptor>src/assembly/zip.xml</descriptor>
-             </descriptors>
-             <appendAssemblyId>false</appendAssemblyId>
-           </configuration>
-         </execution>
-       </executions>
+        <artifactId>maven-assembly-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>generate-complete-zip</id>
+            <phase>package</phase>
+            <goals>
+              <goal>single</goal>
+            </goals>
+            <configuration>
+              <descriptors>
+                <descriptor>src/assembly/zip.xml</descriptor>
+              </descriptors>
+              <appendAssemblyId>false</appendAssemblyId>
+            </configuration>
+          </execution>
+        </executions>
       </plugin>
     </plugins>
   </build>
index f3392e1..c2d19cb 100644 (file)
@@ -3,6 +3,7 @@
   PDP-D APPS Installation Package
   ================================================================================
   Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+  Modifications Copyright (C) 2019 Bell Canada.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   -->
 
 <assembly>
-       <id>zipfile</id>
-       <formats>
-               <format>zip</format>
-       </formats>
-       <includeBaseDirectory>false</includeBaseDirectory>
-       <fileSets>
-               <fileSet>
-                       <directory>src/files</directory>
-                       <outputDirectory>.</outputDirectory>
-                       <fileMode>755</fileMode>
-               </fileSet>
-       </fileSets>
-       <dependencySets>
-               <dependencySet>
-                       <useTransitiveDependencies>false</useTransitiveDependencies>
-               </dependencySet>
-       </dependencySets>
+    <id>zipfile</id>
+    <formats>
+        <format>zip</format>
+    </formats>
+    <includeBaseDirectory>false</includeBaseDirectory>
+    <fileSets>
+        <fileSet>
+            <directory>src/files</directory>
+            <outputDirectory>.</outputDirectory>
+            <fileMode>755</fileMode>
+        </fileSet>
+    </fileSets>
+    <dependencySets>
+        <dependencySet>
+            <useTransitiveDependencies>false</useTransitiveDependencies>
+        </dependencySet>
+    </dependencySets>
 </assembly>
 
index e7c4b93..526d3fb 100644 (file)
@@ -3,6 +3,7 @@
   ONAP
   ================================================================================
   Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+  Modifications Copyright (C) 2019 Bell Canada.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
     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>org.onap.policy.drools-applications.controlloop.packages</groupId>
         <artifactId>packages</artifactId>
         <version>1.5.0-SNAPSHOT</version>
     </parent>
-
     <artifactId>docker-controlloop</artifactId>
     <packaging>pom</packaging>
 
     <name>docker-controlloop</name>
     <description>ONAP Policy Control Loop PDP-D Docker Build</description>
 
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+        <dist.project.version>${project.version}</dist.project.version>
+        <docker.skip>false</docker.skip>
+        <docker.skip.build>false</docker.skip.build>
+        <docker.skip.push>false</docker.skip.push>
+        <docker.pull.registry>nexus3.onap.org:10001</docker.pull.registry>
+        <docker.push.registry>nexus3.onap.org:10003</docker.push.registry>
+        <maven.build.timestamp.format>yyyyMMdd'T'HHmm</maven.build.timestamp.format>
+        <docker.buildArg.BUILD_VERSION_APP_CL>${project.version}</docker.buildArg.BUILD_VERSION_APP_CL>
+    </properties>
+
     <build>
+        <finalName>${project.artifactId}-${project.version}</finalName>
         <plugins>
             <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-dependency-plugin</artifactId>
+                <groupId>org.codehaus.groovy.maven</groupId>
+                <artifactId>gmaven-plugin</artifactId>
+                <version>1.0</version>
                 <executions>
                     <execution>
-                        <id>copy-cl-apps-zip</id>
-                        <phase>prepare-package</phase>
+                        <phase>validate</phase>
                         <goals>
-                            <goal>copy</goal>
+                            <goal>execute</goal>
                         </goals>
                         <configuration>
-                            <outputDirectory>${project.build.directory}/policy-pdpd-cl</outputDirectory>
-                            <overWriteReleases>false</overWriteReleases>
-                            <overWriteSnapshots>true</overWriteSnapshots>
-                            <artifactItems>
-                                <artifactItem>
-                                    <groupId>org.onap.policy.drools-applications.controlloop.packages</groupId>
-                                    <artifactId>apps-controlloop</artifactId>
-                                    <version>${project.version}</version>
-                                    <type>zip</type>
-                                    <destFileName>apps-controlloop.zip</destFileName>
-                                </artifactItem>
-                            </artifactItems>
+                            <source>
+                                println 'Project version: ' + project.properties['dist.project.version']
+                                if (project.properties['dist.project.version'] != null) {
+                                    def versionArray = project.properties['dist.project.version'].split('-')
+                                    def minMaxVersionArray = versionArray[0].tokenize('.')
+                                    if (project.properties['dist.project.version'].endsWith("-SNAPSHOT")) {
+                                        project.properties['project.docker.latest.minmax.tag.version'] =
+                                            minMaxVersionArray[0] + "." + minMaxVersionArray[1] + "-SNAPSHOT-latest"
+                                    } else {
+                                        project.properties['project.docker.latest.minmax.tag.version'] =
+                                            minMaxVersionArray[0] + "." + minMaxVersionArray[1] + "-STAGING-latest"
+                                    }
+                                    println 'New tag for docker: ' + properties['project.docker.latest.minmax.tag.version']
+                                }
+                            </source>
                         </configuration>
                     </execution>
                 </executions>
             </plugin>
             <plugin>
-                <artifactId>maven-resources-plugin</artifactId>
+                <groupId>io.fabric8</groupId>
+                <artifactId>docker-maven-plugin</artifactId>
+                <version>0.30.0</version> <!-- Extract this as a property from the policy-parent -->
+                <configuration>
+                    <verbose>true</verbose>
+                    <apiVersion>1.23</apiVersion>
+                    <pullRegistry>${docker.pull.registry}</pullRegistry>
+                    <pushRegistry>${docker.push.registry}</pushRegistry>
+                    <images>
+                        <image>
+                            <name>onap/policy-pdpd-cl</name>
+                            <build>
+                                <cleanup>try</cleanup>
+                                <dockerFile>Dockerfile</dockerFile>
+                                <tags>
+                                    <tag>${project.version}</tag>
+                                    <tag>${project.version}-${maven.build.timestamp}</tag>
+                                    <tag>${project.docker.latest.minmax.tag.version}</tag>
+                                </tags>
+                                <assembly>
+                                    <descriptor>${project.basedir}/src/main/assembly/assembly.xml</descriptor>
+                                    <user>policy:policy:policy</user>
+                                </assembly>
+                            </build>
+                        </image>
+                    </images>
+                </configuration>
                 <executions>
                     <execution>
-                        <id>copy-resources</id>
-                        <phase>prepare-package</phase>
+                        <id>clean-images</id>
+                        <phase>pre-clean</phase>
                         <goals>
-                            <goal>copy-resources</goal>
+                            <goal>remove</goal>
                         </goals>
                         <configuration>
-                            <outputDirectory>${project.build.directory}/policy-pdpd-cl</outputDirectory>
-                            <resources>
-                                <resource>
-                                    <directory>src/main/docker</directory>
-                                </resource>
-                            </resources>
+                            <removeAll>true</removeAll>
                         </configuration>
                     </execution>
-                </executions>
-            </plugin>
-
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>exec-maven-plugin</artifactId>
-                <executions>
                     <execution>
-                        <id>get-target-version</id>
-                        <phase>prepare-package</phase>
+                        <id>generate-images</id>
+                        <phase>generate-sources</phase>
                         <goals>
-                            <goal>exec</goal>
+                            <goal>build</goal>
                         </goals>
                     </execution>
+                    <execution>
+                        <id>push-images</id>
+                        <phase>deploy</phase>
+                        <goals>
+                            <goal>build</goal>
+                            <goal>push</goal>
+                        </goals>
+                        <configuration>
+                            <image>onap/policy-pdpd-cl</image>
+                        </configuration>
+                    </execution>
                 </executions>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-deploy-plugin</artifactId>
                 <configuration>
-                    <executable>echo</executable>
-                    <workingDirectory>${project.build.directory}</workingDirectory>
-                    <arguments>
-                        <argument>${project.version}</argument>
-                    </arguments>
-                    <outputFile>${project.build.directory}/version</outputFile>
+                    <skip>true</skip>
                 </configuration>
             </plugin>
-
         </plugins>
     </build>
-
+    <dependencies>
+        <dependency>
+            <groupId>${project.groupId}</groupId>
+            <artifactId>apps-controlloop</artifactId>
+            <version>${project.version}</version>
+            <type>zip</type>
+        </dependency>
+    </dependencies>
 </project>
diff --git a/controlloop/packages/docker-controlloop/src/main/assembly/assembly.xml b/controlloop/packages/docker-controlloop/src/main/assembly/assembly.xml
new file mode 100644 (file)
index 0000000..7deffeb
--- /dev/null
@@ -0,0 +1,45 @@
+<!--
+  ============LICENSE_START=======================================================
+  PDP-D APPS Installation Package
+  ================================================================================
+  Copyright (C) 2019 Bell Canada. All rights reserved.
+  ================================================================================
+  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=========================================================
+  -->
+
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    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>docker-drools-apps</id>
+    <fileSets>
+        <fileSet>
+            <directory>${project.basedir}/src/main/resources</directory>
+            <outputDirectory>.</outputDirectory>
+            <filtered>true</filtered>
+            <includes>
+                <include>docker-entrypoint.sh</include>
+            </includes>
+            <fileMode>755</fileMode>
+        </fileSet>
+    </fileSets>
+    <dependencySets>
+        <dependencySet>
+            <includes>
+                <include>org.onap.policy.drools-applications.controlloop.packages:apps-controlloop</include>
+            </includes>
+            <outputDirectory>.</outputDirectory>
+            <outputFileNameMapping>apps-controlloop.zip</outputFileNameMapping>
+        </dependencySet>
+    </dependencySets>
+</assembly>
index 9f1845d..e1bed07 100644 (file)
@@ -1,35 +1,35 @@
-FROM onap/policy-drools:1.4.0
+FROM onap/policy-drools:1.5.0-SNAPSHOT
 
 ARG BUILD_VERSION_APP_CL=${BUILD_VERSION_APP_CL}
 ENV BUILD_VERSION_APP_CL=${BUILD_VERSION_APP_CL}
 
-COPY apps-controlloop.zip ${POLICY_INSTALL}/
+COPY /maven/apps-controlloop.zip $POLICY_INSTALL/
 
 RUN unzip apps-controlloop.zip && \
-    mkdir -p ${POLICY_HOME}/logs ${POLICY_HOME}/config ${HOME}/.m2 && \
-    tar -C ${POLICY_HOME} -xvf base-${BUILD_VERSION_DROOLS}.tar.gz --no-same-owner && \
-    tar -C ${POLICY_HOME} -xvf basex-controlloop-${BUILD_VERSION_APP_CL}.tar.gz --no-same-owner && \
-    unzip policy-management-${BUILD_VERSION_DROOLS}.zip -d ${POLICY_HOME} && \
-    echo "source ${POLICY_HOME}/etc/profile.d/env.sh" >> "${HOME}/.bashrc" && \
-    chmod 700 ${POLICY_HOME}/bin/* && \
-    chmod 600 ${POLICY_HOME}/config/* && \
-    chmod 700 ${POLICY_INSTALL}/*.sh && \
-    rm -f ${POLICY_INSTALL}/*.conf
+    mkdir -p $POLICY_HOME/logs $POLICY_HOME/config $HOME/.m2 && \
+    tar -C $POLICY_HOME -xvf base-${BUILD_VERSION_DROOLS}.tar.gz --no-same-owner && \
+    tar -C $POLICY_HOME -xvf basex-controlloop-$BUILD_VERSION_APP_CL.tar.gz --no-same-owner && \
+    unzip policy-management-${BUILD_VERSION_DROOLS}.zip -d $POLICY_HOME && \
+    echo "source $POLICY_HOME/etc/profile.d/env.sh" >> "$HOME/.bashrc" && \
+    chmod 700 $POLICY_HOME/bin/* && \
+    chmod 600 $POLICY_HOME/config/* && \
+    chmod 700 $POLICY_INSTALL/*.sh && \
+    rm -f $POLICY_INSTALL/*.conf
 
-COPY docker-entrypoint.sh ${POLICY_HOME}/bin/
+COPY /maven/docker-entrypoint.sh $POLICY_HOME/bin/
 
-RUN . ${POLICY_HOME}/etc/profile.d/env.sh && \
+RUN . $POLICY_HOME/etc/profile.d/env.sh && \
     mvn org.apache.maven.plugins:maven-dependency-plugin:3.1.1:get \
-        --settings=${POLICY_HOME}/etc/m2/standalone-settings.xml \
+        --settings=$POLICY_HOME/etc/m2/standalone-settings.xml \
         -DartifactId=feature-controlloop-management \
-        -DgroupId=org.onap.policy.drools-applications.controlloop.common -Dversion=${BUILD_VERSION_APP_CL} && \
-    ${POLICY_HOME}/bin/features install healthcheck distributed-locking lifecycle && \
-    ${POLICY_HOME}/bin/features install controlloop-utils controlloop-trans controlloop-management && \
-    ${POLICY_HOME}/bin/features install controlloop-amsterdam controlloop-usecases && \
-    ${POLICY_HOME}/bin/features enable healthcheck distributed-locking lifecycle && \
-    ${POLICY_HOME}/bin/features enable controlloop-trans controlloop-management && \
-    ${POLICY_HOME}/bin/features enable controlloop-amsterdam controlloop-usecases && \
-    rm ${POLICY_INSTALL}/*.zip ${POLICY_INSTALL}/*.gz 2> /dev/null
+        -DgroupId=org.onap.policy.drools-applications.controlloop.common -Dversion=$BUILD_VERSION_APP_CL && \
+    $POLICY_HOME/bin/features install healthcheck distributed-locking lifecycle && \
+    $POLICY_HOME/bin/features install controlloop-utils controlloop-trans controlloop-management && \
+    $POLICY_HOME/bin/features install controlloop-amsterdam controlloop-usecases && \
+    $POLICY_HOME/bin/features enable healthcheck distributed-locking lifecycle && \
+    $POLICY_HOME/bin/features enable controlloop-trans controlloop-management && \
+    $POLICY_HOME/bin/features enable controlloop-amsterdam controlloop-usecases && \
+    rm $POLICY_INSTALL/*.zip $POLICY_INSTALL/*.gz 2> /dev/null
 
 ENTRYPOINT ["/opt/app/policy/bin/docker-entrypoint.sh"]
 CMD ["boot"]
index cda9cfe..aa3dc97 100644 (file)
@@ -3,6 +3,7 @@
   Drools PDP Application Models
   ================================================================================
   Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
+  Modifications Copyright (C) 2019 Bell Canada.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with 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">
+<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>
   <packaging>pom</packaging>
-
   <parent>
     <groupId>org.onap.policy.drools-applications.controlloop</groupId>
     <artifactId>controlloop</artifactId>
     <version>1.5.0-SNAPSHOT</version>
   </parent>
-
   <groupId>org.onap.policy.drools-applications.controlloop.packages</groupId>
   <artifactId>packages</artifactId>
-
   <name>PDP-D Application Installation Packages</name>
   <description>PDP-D Installation</description>
-
-  <modules>
-    <module>basex-controlloop</module>
-    <module>artifacts-controlloop</module>
-    <module>apps-controlloop</module>
-    <module>docker-controlloop</module>
-  </modules>
+  <profiles>
+    <profile>
+      <id>default</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+    </profile>
+    <profile>
+      <id>docker</id>
+      <modules>
+        <module>basex-controlloop</module>
+        <module>artifacts-controlloop</module>
+        <module>apps-controlloop</module>
+        <module>docker-controlloop</module>
+      </modules>
+      <properties>
+        <docker.skip.push>false</docker.skip.push>
+      </properties>
+    </profile>
+  </profiles>
 </project>