Update to use fabric io docker plugin 05/84005/1
authorTimoney, Dan (dt5972) <dtimoney@att.com>
Tue, 2 Apr 2019 19:53:53 +0000 (12:53 -0700)
committerTimoney, Dan (dt5972) <dtimoney@att.com>
Tue, 2 Apr 2019 19:53:53 +0000 (12:53 -0700)
Update to use fabric io docker plugin to create docker image

Change-Id: I6b068a3224bf9af9cc8c3b2e43dbb3af377d54b7
Issue-ID: CCSDK-1011
Signed-off-by: Timoney, Dan (dt5972) <dtimoney@att.com>
TagVersion.groovy [new file with mode: 0644]
ccsdk-app-os/pom.xml

diff --git a/TagVersion.groovy b/TagVersion.groovy
new file mode 100644 (file)
index 0000000..68a8b78
--- /dev/null
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CCSDK
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. 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============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.ccsdk.distribution
+
+
+def versionArray;
+if ( project.properties['ccsdk.project.version'] != null ) {
+       versionArray = project.properties['ccsdk.project.version'].split('\\.');
+}
+
+if ( project.properties['ccsdk.project.version'].endsWith("-SNAPSHOT") ) {
+       patchArray = versionArray[2].split('-');
+       project.properties['project.docker.latestminortag.version']=versionArray[0] + '.' + versionArray[1] + "-SNAPSHOT-latest";
+       project.properties['project.docker.latestfulltag.version']=versionArray[0] + '.' + versionArray[1] + '.' + patchArray[0] + "-SNAPSHOT-latest";
+       project.properties['project.docker.latesttagtimestamp.version']=versionArray[0] + '.' + versionArray[1] + '.' + patchArray[0] + "-SNAPSHOT-"+project.properties['ccsdk.build.timestamp'];
+} else {
+       project.properties['project.docker.latestminortag.version']=versionArray[0] + '.' + versionArray[1] + "-STAGING-latest";
+       project.properties['project.docker.latestfulltag.version']=versionArray[0] + '.' + versionArray[1] + '.' + versionArray[2] + "-STAGING-latest";
+       project.properties['project.docker.latesttagtimestamp.version']=versionArray[0] + '.' + versionArray[1] + '.' + versionArray[2] + "-STAGING-"+project.properties['ccsdk.build.timestamp'];
+}
index 7744dda..a7c7f58 100644 (file)
                <build.version>${project.version}</build.version>
                <!-- Tests usually require some setup that maven cannot do, so skip. -->
                <skiptests>true</skiptests>
-               <docker.image.name>onap/${project.groupId}.${project.artifactId}</docker.image.name>
-               <docker.push.registry>nexus3.onap.org:10003</docker.push.registry>
-               <image-name>${docker.push.registry}/${docker.image.name}</image-name>
+               
+               <image.name>onap/${project.groupId}.${project.artifactId}</image.name>
+               <ccsdk.project.version>${project.version}</ccsdk.project.version>
+               <ccsdk.build.timestamp>${maven.build.timestamp}</ccsdk.build.timestamp>
+               <ccsdk.distribution.version>${project.version}</ccsdk.distribution.version>
+               <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
+               <docker.verbose>true</docker.verbose>
        </properties>
 
+
        <repositories>
                <repository>
                        <!-- Releases repository has ECOMP release artifacts -->
                                        <target>1.8</target>
                                </configuration>
                        </plugin>
-
+                       <plugin>
+                               <groupId>org.codehaus.groovy.maven</groupId>
+                               <artifactId>gmaven-plugin</artifactId>
+                               <executions>
+                                       <execution>
+                                               <phase>validate</phase>
+                                               <goals>
+                                                       <goal>execute</goal>
+                                               </goals>
+                                               <configuration>
+                                                       <source>${basedir}/../TagVersion.groovy</source>
+                                               </configuration>
+                                       </execution>
+                               </executions>
+                       </plugin>
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                                <artifactId>maven-war-plugin</artifactId>
                                        </overlays>
                                </configuration>
                        </plugin>
-                       <plugin>
-                               <groupId>com.spotify</groupId>
-                               <artifactId>dockerfile-maven-plugin</artifactId>
-                               <version>1.4.10</version>
-                               <configuration>
-                                       <useMavenSettingsForAuth>true</useMavenSettingsForAuth>
-                                       <repository>${image-name}</repository>
-                               <tag>latest</tag>
-                               <dockerfile>Dockerfile</dockerfile>
-                               <buildArgs>
-                               <WAR_FILE>${project.build.finalName}.war</WAR_FILE>
-                               </buildArgs>
-                       </configuration>
-                                 <executions>
-                                   <execution>
-                                     <id>default</id>
-                                     <goals>
-                                       <goal>build</goal>
-                                       <goal>push</goal>
-                                     </goals>
-                                   </execution>
-                                 </executions>
-                       </plugin>
+
                        <!-- no deployment needed -->
                        <plugin>
                                <groupId>org.apache.maven.plugins</groupId>
                        </plugin>
                </plugins>
        </build>
+       
+       <profiles>
+               <profile>
+                       <id>docker</id>
+                       <build>
+                               <plugins>
+                                       <plugin>
+                                               <groupId>io.fabric8</groupId>
+                                               <artifactId>docker-maven-plugin</artifactId>
+                                               <version>0.28.0</version>
+                                               <inherited>false</inherited>
+                                               <configuration>
+                                                       <images>
+                                                               <image>
+                                                                       <name>${image.name}</name>
+                                                                       <build>
+                                                                               <cleanup>try</cleanup>
+                                                                               <dockerFileDir>${basedir}</dockerFileDir>
+                                                                               <dockerFile>Dockerfile</dockerFile>
+                                                                               <tags>
+                                                                                       <tag>${project.docker.latestminortag.version}</tag>
+                                                                                       <tag>${project.docker.latestfulltag.version}</tag>
+                                                                                       <tag>${project.docker.latesttagtimestamp.version}</tag>
+                                                                               </tags>
+                                                                       </build>
+                                                               </image>
+                                                       </images>
+                                               </configuration>
+                                               <executions>
+                                                       <execution>
+                                                               <id>generate-images</id>
+                                                               <phase>package</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>
+                               </plugins>
+                       </build>
+               </profile>
+       </profiles>
 
        <dependencies>
                <!-- ECD webapp resources -->