From 86359a2f445a19a19d8239f2e7e07480a1bc7ba3 Mon Sep 17 00:00:00 2001 From: Dmitry Puzikov Date: Tue, 16 Apr 2019 16:52:05 +0200 Subject: Fixed version parsing Change-Id: Ibd37f998820dd4a77a6c320ce6b1066b06c86f51 Issue-ID: INT-798 Signed-off-by: Dmitry Puzikov --- .gitignore | 2 + pom.xml | 183 +++++++++++++++++++++++++++++---------- src/main/assembly/descriptor.xml | 36 ++++++++ src/main/bin/start.sh | 11 ++- src/main/docker/Dockerfile | 24 ++--- 5 files changed, 191 insertions(+), 65 deletions(-) create mode 100644 src/main/assembly/descriptor.xml 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 25b4d67..8dc1cd1 100644 --- a/pom.xml +++ b/pom.xml @@ -59,6 +59,15 @@ 1.2.1 1.3.0 1.2.3 + + 0.28.0 + 1.0.0 + ${project.build.directory}/${project.artifactId}-${project.version}-build/ + onap + alpine + 1.6.0 + + yyyyMMdd'T'HHmmss'Z' @@ -74,6 +83,118 @@ + + + + docker + + + + org.codehaus.mojo + build-helper-maven-plugin + 3.0.0 + + + pre-clean + parse-version + + parse-version + + + + + + org.codehaus.groovy.maven + gmaven-plugin + 1.0 + + + pre-clean + + execute + + + + 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']; + + + + + + + io.fabric8 + docker-maven-plugin + ${docker.fabric.version} + + true + 1.23 + + + ${docker.push.registry}/${aai.docker.namespace}/${project.artifactId}:%l + + @ + + latest + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-${maven.build.timestamp} + + try + ${project.basedir}/src/main/docker + + + + + ${aai.build.directory} + /${project.artifactId} + + + + + + + + + + + clean-images + pre-clean + + remove + + + true + + + + generate-images + package + + build + + + + push-images + deploy + + push + + + + + + + + + org.springframework.boot @@ -236,7 +357,6 @@ - model-loader org.springframework.boot @@ -253,36 +373,6 @@ - - org.apache.maven.plugins - maven-resources-plugin - 2.7 - - - copy-docker-file - package - - copy-resources - - - target - true - - - ${basedir}/src/main/docker - true - - **/* - - - - ${basedir}/src/main/bin/ - - - - - - com.mycila license-maven-plugin @@ -308,23 +398,28 @@ - com.spotify - docker-maven-plugin - 0.4.11 + org.apache.maven.plugins + maven-deploy-plugin - true - docker-hub - ${docker.push.registry}/onap/${project.artifactId} - ${docker.location} - - latest - - true + true - org.apache.maven.plugins - maven-deploy-plugin + maven-assembly-plugin + + + src/main/assembly/descriptor.xml + + + + + make-assembly + package + + single + + + 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 @@ + + build + false + + dir + + + + ${project.basedir}/src/main/resources + / + + logback.xml + + + + ${project.basedir}/src/main/bin + /bin + + **/* + + + + ${project.build.directory} + / + + *.jar + + + Dockerfile + *.sh + + + + 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"] -- cgit 1.2.3-korg