Fixed version parsing 94/92794/6
authorDmitry Puzikov <dmitry.puzikov@tieto.com>
Tue, 16 Apr 2019 14:52:05 +0000 (16:52 +0200)
committerDmitry Puzikov <dmitry.puzikov@tieto.com>
Thu, 29 Aug 2019 07:23:11 +0000 (09:23 +0200)
Change-Id: Ibd37f998820dd4a77a6c320ce6b1066b06c86f51
Issue-ID: INT-798
Signed-off-by: Dmitry Puzikov <dmitry.puzikov@tieto.com>
.gitignore
pom.xml
src/main/assembly/descriptor.xml [new file with mode: 0644]
src/main/bin/start.sh
src/main/docker/Dockerfile

index 363b131..56f75e2 100644 (file)
@@ -5,3 +5,5 @@ target/
 logs/
 debug-logs/
 .checkstyle
 logs/
 debug-logs/
 .checkstyle
+.idea/
+*.iml
diff --git a/pom.xml b/pom.xml
index 25b4d67..8dc1cd1 100644 (file)
--- a/pom.xml
+++ b/pom.xml
                <aai.rest.client.version>1.2.1</aai.rest.client.version>
                <sdc-distribution-client.version>1.3.0</sdc-distribution-client.version>
                <logback.version>1.2.3</logback.version>
                <aai.rest.client.version>1.2.1</aai.rest.client.version>
                <sdc-distribution-client.version>1.3.0</sdc-distribution-client.version>
                <logback.version>1.2.3</logback.version>
+               <!-- docker related properties -->
+               <docker.fabric.version>0.28.0</docker.fabric.version>
+               <aai.docker.version>1.0.0</aai.docker.version>
+               <aai.build.directory>${project.build.directory}/${project.artifactId}-${project.version}-build/</aai.build.directory>
+               <aai.docker.namespace>onap</aai.docker.namespace>
+               <aai.base.image>alpine</aai.base.image>
+               <aai.base.image.version>1.6.0</aai.base.image.version>
+               <!-- This will be used for the docker images as the default format of maven build has issues -->
+               <maven.build.timestamp.format>yyyyMMdd'T'HHmmss'Z'</maven.build.timestamp.format>
        </properties>
 
        <distributionManagement>
        </properties>
 
        <distributionManagement>
                </snapshotRepository>
        </distributionManagement>
 
                </snapshotRepository>
        </distributionManagement>
 
+       <profiles>
+               <!-- Docker profile to be used for building docker image and pushing to nexus -->
+               <profile>
+                       <id>docker</id>
+                       <build>
+                               <plugins>
+                                       <plugin>
+                                               <groupId>org.codehaus.mojo</groupId>
+                                               <artifactId>build-helper-maven-plugin</artifactId>
+                                               <version>3.0.0</version>
+                                               <executions>
+                                                       <execution>
+                                                               <phase>pre-clean</phase>
+                                                               <id>parse-version</id>
+                                                               <goals>
+                                                                       <goal>parse-version</goal>
+                                                               </goals>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                                       <plugin>
+                                               <groupId>org.codehaus.groovy.maven</groupId>
+                                               <artifactId>gmaven-plugin</artifactId>
+                                               <version>1.0</version>
+                                               <executions>
+                                                       <execution>
+                                                               <phase>pre-clean</phase>
+                                                               <goals>
+                                                                       <goal>execute</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <source>
+                                                                               def userAaiBaseImage = session.userProperties['aai.base.image'];
+                                                                               def userAaiCommonVersion = session.userProperties['aai.base.image.version'];
+                                                                               if (userAaiCommonVersion != null) {
+                                                                                       project.properties['aai.base.image.version'] = userAaiCommonVersion;
+                                                                               }
+                                                                               if (userAaiBaseImage != null) {
+                                                                                       project.properties['aai.base.image'] = userAaiBaseImage;
+                                                                               }
+                                                                               log.info 'Base image flavour: ' + project.properties['aai.base.image'];
+                                                                               log.info 'Base image version: ' + project.properties['aai.base.image.version'];
+                                                                       </source>
+                                                               </configuration>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                                       <plugin>
+                                               <groupId>io.fabric8</groupId>
+                                               <artifactId>docker-maven-plugin</artifactId>
+                                               <version>${docker.fabric.version}</version>
+                                               <configuration>
+                                                       <verbose>true</verbose>
+                                                       <apiVersion>1.23</apiVersion>
+                                                       <images>
+                                                               <image>
+                                                                       <name>${docker.push.registry}/${aai.docker.namespace}/${project.artifactId}:%l</name>
+                                                                       <build>
+                                                                               <filter>@</filter>
+                                                                               <tags>
+                                                                                       <tag>latest</tag>
+                                                                                       <tag>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest</tag>
+                                                                                       <tag>${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-${maven.build.timestamp}</tag>
+                                                                               </tags>
+                                                                               <cleanup>try</cleanup>
+                                                                               <dockerFileDir>${project.basedir}/src/main/docker</dockerFileDir>
+                                                                               <assembly>
+                                                                                       <inline>
+                                                                                               <fileSets>
+                                                                                                       <fileSet>
+                                                                                                               <directory>${aai.build.directory}</directory>
+                                                                                                               <outputDirectory>/${project.artifactId}</outputDirectory>
+                                                                                                       </fileSet>
+                                                                                               </fileSets>
+                                                                                       </inline>
+                                                                               </assembly>
+                                                                       </build>
+                                                               </image>
+                                                       </images>
+                                               </configuration>
+                                               <executions>
+                                                       <execution>
+                                                               <id>clean-images</id>
+                                                               <phase>pre-clean</phase>
+                                                               <goals>
+                                                                       <goal>remove</goal>
+                                                               </goals>
+                                                               <configuration>
+                                                                       <removeAll>true</removeAll>
+                                                               </configuration>
+                                                       </execution>
+                                                       <execution>
+                                                               <id>generate-images</id>
+                                                               <phase>package</phase>
+                                                               <goals>
+                                                                       <goal>build</goal>
+                                                               </goals>
+                                                       </execution>
+                                                       <execution>
+                                                               <id>push-images</id>
+                                                               <phase>deploy</phase>
+                                                               <goals>
+                                                                       <goal>push</goal>
+                                                               </goals>
+                                                       </execution>
+                                               </executions>
+                                       </plugin>
+                               </plugins>
+                       </build>
+               </profile>
+       </profiles>
+
        <dependencies>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
        <dependencies>
                <dependency>
                        <groupId>org.springframework.boot</groupId>
        </repositories>
 
        <build>
        </repositories>
 
        <build>
-               <finalName>model-loader</finalName>
                <plugins>
                        <plugin>
                                <groupId>org.springframework.boot</groupId>
                <plugins>
                        <plugin>
                                <groupId>org.springframework.boot</groupId>
                                        </execution>
                                </executions>
                        </plugin>
                                        </execution>
                                </executions>
                        </plugin>
-                       <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-resources-plugin</artifactId>
-                               <version>2.7</version>
-                               <executions>
-                                       <execution>
-                                               <id>copy-docker-file</id>
-                                               <phase>package</phase>
-                                               <goals>
-                                                       <goal>copy-resources</goal>
-                                               </goals>
-                                               <configuration>
-                                                       <outputDirectory>target</outputDirectory>
-                                                       <overwrite>true</overwrite>
-                                                       <resources>
-                                                               <resource>
-                                                                       <directory>${basedir}/src/main/docker</directory>
-                                                                       <filtering>true</filtering>
-                                                                       <includes>
-                                                                               <include>**/*</include>
-                                                                       </includes>
-                                                               </resource>
-                                                               <resource>
-                                                                       <directory>${basedir}/src/main/bin/</directory>
-                                                               </resource>
-                                                       </resources>
-                                               </configuration>
-                                       </execution>
-                               </executions>
-                       </plugin>
                        <plugin>
                                <groupId>com.mycila</groupId>
                                <artifactId>license-maven-plugin</artifactId>
                        <plugin>
                                <groupId>com.mycila</groupId>
                                <artifactId>license-maven-plugin</artifactId>
                                </executions>
                        </plugin>
                        <plugin>
                                </executions>
                        </plugin>
                        <plugin>
-                               <groupId>com.spotify</groupId>
-                               <artifactId>docker-maven-plugin</artifactId>
-                               <version>0.4.11</version>
+                               <groupId>org.apache.maven.plugins</groupId>
+                               <artifactId>maven-deploy-plugin</artifactId>
                                <configuration>
                                <configuration>
-                                       <verbose>true</verbose>
-                                       <serverId>docker-hub</serverId>
-                                       <imageName>${docker.push.registry}/onap/${project.artifactId}</imageName>
-                                       <dockerDirectory>${docker.location}</dockerDirectory>
-                                       <imageTags>
-                                               <imageTag>latest</imageTag>
-                                       </imageTags>
-                                       <forceTags>true</forceTags>
+                                       <skip>true</skip>
                                </configuration>
                        </plugin>
                        <plugin>
                                </configuration>
                        </plugin>
                        <plugin>
-                               <groupId>org.apache.maven.plugins</groupId>
-                               <artifactId>maven-deploy-plugin</artifactId>
+                               <artifactId>maven-assembly-plugin</artifactId>
+                               <configuration>
+                                       <descriptors>
+                                               <descriptor>src/main/assembly/descriptor.xml</descriptor>
+                                       </descriptors>
+                               </configuration>
+                               <executions>
+                                       <execution>
+                                               <id>make-assembly</id>
+                                               <phase>package</phase>
+                                               <goals>
+                                                       <goal>single</goal>
+                                               </goals>
+                                       </execution>
+                               </executions>
                        </plugin>
                </plugins>
        </build>
                        </plugin>
                </plugins>
        </build>
diff --git a/src/main/assembly/descriptor.xml b/src/main/assembly/descriptor.xml
new file mode 100644 (file)
index 0000000..1d88931
--- /dev/null
@@ -0,0 +1,36 @@
+<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"\r
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+          xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">\r
+    <id>build</id>\r
+    <includeBaseDirectory>false</includeBaseDirectory>\r
+    <formats>\r
+        <format>dir</format>\r
+    </formats>\r
+    <fileSets>\r
+        <fileSet>\r
+            <directory>${project.basedir}/src/main/resources</directory>\r
+            <outputDirectory>/</outputDirectory>\r
+            <includes>\r
+                <include>logback.xml</include>\r
+            </includes>\r
+        </fileSet>\r
+        <fileSet>\r
+            <directory>${project.basedir}/src/main/bin</directory>\r
+            <outputDirectory>/bin</outputDirectory>\r
+            <includes>\r
+                <include>**/*</include>\r
+            </includes>\r
+        </fileSet>\r
+        <fileSet>\r
+            <directory>${project.build.directory}</directory>\r
+            <outputDirectory>/</outputDirectory>\r
+            <includes>\r
+                <include>*.jar</include>\r
+            </includes>\r
+            <excludes>\r
+                <exclude>Dockerfile</exclude>\r
+                <exclude>*.sh</exclude>\r
+            </excludes>\r
+        </fileSet>\r
+    </fileSets>\r
+</assembly>\r
index 038f4df..1dedb25 100644 (file)
 #  ============LICENSE_END============================================
 #*******************************************************************************
 
 #  ============LICENSE_END============================================
 #*******************************************************************************
 
+# jre-alpine image has $JAVA_HOME set and added to $PATH
+# ubuntu image requires to set $JAVA_HOME and add java to $PATH manually
+if ( uname -v | grep -i "ubuntu" ); then
+    export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-`dpkg --print-architecture | awk -F- '{ print $NF }'`
+    export PATH=${JAVA_HOME}:$PATH
+fi
+
 # AJSC_HOME is required for EELF logging.
 # This path is referenced in the file logback.xml.
 AJSC_HOME="${AJSC_HOME-/opt/app/model-loader}"
 # AJSC_HOME is required for EELF logging.
 # This path is referenced in the file logback.xml.
 AJSC_HOME="${AJSC_HOME-/opt/app/model-loader}"
@@ -30,8 +37,6 @@ if [ -z "$CONFIG_HOME" ]; then
     exit 1
 fi
 
     exit 1
 fi
 
-JARFILE="$AJSC_HOME/model-loader.jar"
-
 # Some properties are repeated here for debugging purposes.
 PROPS="-DAJSC_HOME=$AJSC_HOME"
 PROPS="$PROPS -DCONFIG_HOME=$CONFIG_HOME"
 # Some properties are repeated here for debugging purposes.
 PROPS="-DAJSC_HOME=$AJSC_HOME"
 PROPS="$PROPS -DCONFIG_HOME=$CONFIG_HOME"
@@ -52,5 +57,7 @@ if [ -z "${java_runtime_arguments}" ]; then
  -Djava.rmi.server.hostname=127.0.0.1"
 fi
 
  -Djava.rmi.server.hostname=127.0.0.1"
 fi
 
+JARFILE=$(ls ./model-loader*.jar);
+
 echo "java $java_runtime_arguments $PROPS -jar $JARFILE"
 java $java_runtime_arguments $PROPS -jar $JARFILE
 echo "java $java_runtime_arguments $PROPS -jar $JARFILE"
 java $java_runtime_arguments $PROPS -jar $JARFILE
index db67dd9..a523778 100644 (file)
@@ -1,26 +1,12 @@
-FROM ubuntu:14.04
+FROM @aai.docker.namespace@/aai-common-@aai.base.image@:@aai.base.image.version@
 
 ARG MICRO_HOME=/opt/app/model-loader
 
 ARG MICRO_HOME=/opt/app/model-loader
-ARG BIN_HOME=$MICRO_HOME/bin
-ARG JAR_FILE=model-loader.jar
-
-RUN apt-get update
-
-# Install and setup java8
-RUN apt-get update && apt-get install -y software-properties-common
-## sudo -E is required to preserve the environment. If you remove that line, it will most likely freeze at this step
-RUN sudo -E add-apt-repository ppa:openjdk-r/ppa && apt-get update && apt-get install -y openjdk-8-jdk
-## Set up JAVA_HOME for docker command-line
-ENV JAVA_HOME usr/lib/jvm/java-8-openjdk-amd64
-RUN export JAVA_HOME
 
 # Build up the deployment folder structure
 RUN mkdir -p $MICRO_HOME
 
 # Build up the deployment folder structure
 RUN mkdir -p $MICRO_HOME
-COPY ${JAR_FILE} $MICRO_HOME/
-COPY classes/logback.xml $MICRO_HOME/
-RUN mkdir -p $BIN_HOME
-COPY *.sh $BIN_HOME
-RUN chmod 755 $BIN_HOME/*
-RUN ln -s /logs $MICRO_HOME/logs
+WORKDIR $MICRO_HOME
+COPY /maven/model-loader/ .
+RUN chmod 755 bin/* \
+    && ln -s /logs $MICRO_HOME/logs
 
 CMD ["/opt/app/model-loader/bin/start.sh"]
 
 CMD ["/opt/app/model-loader/bin/start.sh"]