summaryrefslogtreecommitdiffstats
path: root/packages/docker
diff options
context:
space:
mode:
authorRashmi Pujar <rashmi.pujar@bell.ca>2019-06-03 21:45:58 -0400
committerRashmi Pujar <rashmi.pujar@bell.ca>2019-06-11 07:31:20 -0400
commit7937bce5b0289ba186189f42b1832e8c854c5d83 (patch)
treea5f8605e6cef42e8c7cd96fa219998bbdf3ef687 /packages/docker
parent8ff6558772997899f52a6544861f9ed608b08b38 (diff)
Use io.fabric8:docker-maven-plugin to build and push docker images
Addressed POLICY-1808 for drools-pdp 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: I21cd6080972ddf8cf357d6c134203b92fa9eb09b
Diffstat (limited to 'packages/docker')
-rw-r--r--packages/docker/pom.xml145
-rw-r--r--packages/docker/src/main/docker/Dockerfile26
2 files changed, 112 insertions, 59 deletions
diff --git a/packages/docker/pom.xml b/packages/docker/pom.xml
index 8bfc437e..390e1371 100644
--- a/packages/docker/pom.xml
+++ b/packages/docker/pom.xml
@@ -3,6 +3,7 @@
ONAP Policy Engine - Docker files
================================================================================
Copyright (C) 2017-2018 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.
@@ -34,82 +35,134 @@
<description>ONAP Policy Drools PDP Docker Build</description>
<properties>
- <nexusproxy>https://nexus.onap.org</nexusproxy>
+ <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_DROOLS>${project.version}</docker.buildArg.BUILD_VERSION_DROOLS>
</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-drools-zip</id>
- <phase>prepare-package</phase>
+ <phase>validate</phase>
<goals>
- <goal>copy</goal>
+ <goal>execute</goal>
</goals>
<configuration>
- <outputDirectory>${project.build.directory}/policy-drools</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>true</overWriteSnapshots>
- <artifactItems>
- <artifactItem>
- <groupId>org.onap.policy.drools-pdp</groupId>
- <artifactId>install-drools</artifactId>
- <version>${project.version}</version>
- <type>zip</type>
- <destFileName>install-drools.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: ' + project.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-drools</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>
+ <inline>
+ <dependencySets>
+ <dependencySet>
+ <includes>
+ <include>org.onap.policy.drools-pdp:install-drools</include>
+ </includes>
+ <outputDirectory>.</outputDirectory>
+ <outputFileNameMapping>install-drools.zip</outputFileNameMapping>
+ </dependencySet>
+ </dependencySets>
+ </inline>
+ </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-drools</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-drools</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>install-drools</artifactId>
+ <version>${project.version}</version>
+ <type>zip</type>
+ </dependency>
+ </dependencies>
</project>
diff --git a/packages/docker/src/main/docker/Dockerfile b/packages/docker/src/main/docker/Dockerfile
index 5c060ff2..d2fbf471 100644
--- a/packages/docker/src/main/docker/Dockerfile
+++ b/packages/docker/src/main/docker/Dockerfile
@@ -6,12 +6,12 @@ ARG BUILD_VERSION_DROOLS=${BUILD_VERSION_DROOLS}
ARG POLICY_LOGS=/var/log/onap/policy/pdpd
ARG POLICY_INSTALL=/tmp/policy-install
-ENV BUILD_VERSION_DROOLS ${BUILD_VERSION_DROOLS}
-ENV POLICY_INSTALL ${POLICY_INSTALL}
-ENV POLICY_INSTALL_INIT ${POLICY_INSTALL}/config
-ENV POLICY_LOGS ${POLICY_LOGS}
-ENV POLICY_CONFIG ${POLICY_HOME}/config
-ENV POLICY_LOGBACK ${POLICY_CONFIG}/logback.xml
+ENV BUILD_VERSION_DROOLS $BUILD_VERSION_DROOLS
+ENV POLICY_INSTALL $POLICY_INSTALL
+ENV POLICY_INSTALL_INIT $POLICY_INSTALL/config
+ENV POLICY_LOGS $POLICY_LOGS
+ENV POLICY_CONFIG $POLICY_HOME/config
+ENV POLICY_LOGBACK $POLICY_CONFIG/logback.xml
ENV POLICY_DOCKER true
RUN apk add --no-cache \
@@ -23,15 +23,15 @@ RUN apk add --no-cache \
vim \
&& pip install http-prompt
-RUN mkdir -p ${POLICY_CONFIG} ${POLICY_LOGS} ${POLICY_INSTALL_INIT} && \
- chown -R policy:policy ${POLICY_HOME} ${POLICY_LOGS} ${POLICY_INSTALL} && \
- rmdir ${POLICY_HOME}/etc/ssl && \
- rmdir ${POLICY_HOME}/etc
+RUN mkdir -p $POLICY_CONFIG $POLICY_LOGS $POLICY_INSTALL_INIT && \
+ chown -R policy:policy $POLICY_HOME $POLICY_LOGS $POLICY_INSTALL && \
+ rmdir $POLICY_HOME/etc/ssl && \
+ rmdir $POLICY_HOME/etc
-WORKDIR ${POLICY_INSTALL}
-COPY install-drools.zip docker-install.sh do-start.sh wait-for-port.sh ./
+WORKDIR $POLICY_INSTALL
+COPY /maven/install-drools.zip docker-install.sh do-start.sh wait-for-port.sh ./
-VOLUME [ "${POLICY_INSTALL_INIT}" ]
+VOLUME [ "$POLICY_INSTALL_INIT" ]
RUN unzip -o install-drools.zip && \
rm install-drools.zip && \