summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--pom.xml183
-rw-r--r--src/main/assembly/descriptor.xml36
-rw-r--r--src/main/bin/start.sh11
-rw-r--r--src/main/docker/Dockerfile24
5 files changed, 191 insertions, 65 deletions
diff --git a/.gitignore b/.gitignore
index 363b131..56f75e2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,3 +5,5 @@ target/
logs/
debug-logs/
.checkstyle
+.idea/
+*.iml
diff --git a/pom.xml b/pom.xml
index 17b8a82..9f46d5c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -59,6 +59,15 @@
<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>
@@ -74,6 +83,118 @@
</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>
@@ -236,7 +357,6 @@
</repositories>
<build>
- <finalName>model-loader</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
@@ -254,36 +374,6 @@
</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>
<version>3.0</version>
@@ -308,23 +398,28 @@
</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>
- <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>
- <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>
diff --git a/src/main/assembly/descriptor.xml b/src/main/assembly/descriptor.xml
new file mode 100644
index 0000000..1d88931
--- /dev/null
+++ b/src/main/assembly/descriptor.xml
@@ -0,0 +1,36 @@
+<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>build</id>
+ <includeBaseDirectory>false</includeBaseDirectory>
+ <formats>
+ <format>dir</format>
+ </formats>
+ <fileSets>
+ <fileSet>
+ <directory>${project.basedir}/src/main/resources</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>logback.xml</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.basedir}/src/main/bin</directory>
+ <outputDirectory>/bin</outputDirectory>
+ <includes>
+ <include>**/*</include>
+ </includes>
+ </fileSet>
+ <fileSet>
+ <directory>${project.build.directory}</directory>
+ <outputDirectory>/</outputDirectory>
+ <includes>
+ <include>*.jar</include>
+ </includes>
+ <excludes>
+ <exclude>Dockerfile</exclude>
+ <exclude>*.sh</exclude>
+ </excludes>
+ </fileSet>
+ </fileSets>
+</assembly>
diff --git a/src/main/bin/start.sh b/src/main/bin/start.sh
index 038f4df..1dedb25 100644
--- a/src/main/bin/start.sh
+++ b/src/main/bin/start.sh
@@ -20,6 +20,13 @@
# ============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}"
@@ -30,8 +37,6 @@ if [ -z "$CONFIG_HOME" ]; then
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"
@@ -52,5 +57,7 @@ if [ -z "${java_runtime_arguments}" ]; then
-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
diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile
index db67dd9..a523778 100644
--- a/src/main/docker/Dockerfile
+++ b/src/main/docker/Dockerfile
@@ -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 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
-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"]