diff options
author | Rashmi Pujar <rashmi.pujar@bell.ca> | 2019-06-17 10:34:49 -0400 |
---|---|---|
committer | Rashmi Pujar <rashmi.pujar@bell.ca> | 2019-06-19 06:22:16 -0400 |
commit | 7b945416da394a3ae3e53a1a9ae8d21f6a4e761e (patch) | |
tree | a86f73cbc96ff35e6f3863f454be6b464fa59aa7 | |
parent | dc2ca16a6d7d8cc13be5716e058add8190ea4479 (diff) |
Use io.fabric8:docker-maven-plugin to build and push docker images
Issue-ID: POLICY-969
Signed-off-by: Rashmi Pujar <rashmi.pujar@bell.ca>
Change-Id: Ia3c7c2d6b77d87848c344f212f4a0266db90426e
-rw-r--r-- | packages/apex-pdp-docker/pom.xml | 148 | ||||
-rw-r--r-- | packages/apex-pdp-docker/src/main/docker/Dockerfile | 22 | ||||
-rw-r--r-- | packages/apex-pdp-package-full/pom.xml | 4 | ||||
-rw-r--r-- | packages/pom.xml | 23 |
4 files changed, 132 insertions, 65 deletions
diff --git a/packages/apex-pdp-docker/pom.xml b/packages/apex-pdp-docker/pom.xml index 272cc1b66..dbba47a3d 100644 --- a/packages/apex-pdp-docker/pom.xml +++ b/packages/apex-pdp-docker/pom.xml @@ -1,6 +1,7 @@ <!-- ============LICENSE_START======================================================= Copyright (C) 2018 Ericsson. 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. @@ -30,81 +31,136 @@ <name>Policy APEX PDP - Docker build</name> <description>ONAP Policy APEX PDP Docker Build</description> + <properties> + <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> + </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-apex-tarball</id> - <phase>prepare-package</phase> + <phase>validate</phase> <goals> - <goal>copy</goal> + <goal>execute</goal> </goals> <configuration> - <outputDirectory>${project.build.directory}/policy-apex-pdp</outputDirectory> - <overWriteReleases>false</overWriteReleases> - <overWriteSnapshots>true</overWriteSnapshots> - <artifactItems> - <artifactItem> - <groupId>org.onap.policy.apex-pdp.packages</groupId> - <artifactId>apex-pdp-package-full</artifactId> - <version>${project.version}</version> - <classifier>tarball</classifier> - <type>tar.gz</type> - <destFileName>apex-pdp-package-full.tar.gz</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: ' + 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-apex-pdp</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.apex-pdp.packages:apex-pdp-package-full</include> + </includes> + <outputDirectory>.</outputDirectory> + <outputFileNameMapping>apex-pdp-package-full.tar.gz</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-apex-pdp</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-apex-pdp</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>apex-pdp-package-full</artifactId> + <version>${project.version}</version> + <type>tar.gz</type> + </dependency> + </dependencies> <profiles> <profile> <id>apexSite</id> @@ -124,4 +180,4 @@ </distributionManagement> </profile> </profiles> -</project>
\ No newline at end of file +</project> diff --git a/packages/apex-pdp-docker/src/main/docker/Dockerfile b/packages/apex-pdp-docker/src/main/docker/Dockerfile index d8ad55733..5ae7a7c7a 100644 --- a/packages/apex-pdp-docker/src/main/docker/Dockerfile +++ b/packages/apex-pdp-docker/src/main/docker/Dockerfile @@ -5,12 +5,9 @@ FROM onap/policy-base-alpine:1.4.0 LABEL maintainer="Policy Team" -ARG BUILD_VERSION=${BUILD_VERSION} ARG POLICY_LOGS=/var/log/onap/policy/apex-pdp - -ENV BUILD_VERSION ${BUILD_VERSION} ENV POLICY_HOME=/opt/app/policy/apex-pdp -ENV POLICY_LOGS=${POLICY_LOGS} +ENV POLICY_LOGS=$POLICY_LOGS RUN apk add --no-cache \ vim \ @@ -20,27 +17,26 @@ RUN apk add --no-cache \ # Create apex user and group RUN addgroup -S apexuser && adduser -S apexuser -G apexuser - # Add Apex-specific directories and set ownership as the Apex admin user -RUN mkdir -p ${POLICY_HOME} \ - && mkdir -p ${POLICY_LOGS} \ - && chown -R apexuser:apexuser ${POLICY_LOGS} +RUN mkdir -p $POLICY_HOME \ + && mkdir -p $POLICY_LOGS \ + && chown -R apexuser:apexuser $POLICY_LOGS # Unpack the tarball RUN mkdir /packages -COPY apex-pdp-package-full.tar.gz /packages -RUN tar xvfz /packages/apex-pdp-package-full.tar.gz --directory ${POLICY_HOME} \ +COPY /maven/apex-pdp-package-full.tar.gz /packages +RUN tar xvfz /packages/apex-pdp-package-full.tar.gz --directory $POLICY_HOME \ && rm /packages/apex-pdp-package-full.tar.gz # Ensure everything has the correct permissions RUN find /opt/app -type d -perm 755 \ && find /opt/app -type f -perm 644 \ - && chmod 755 ${POLICY_HOME}/bin/* + && chmod 755 $POLICY_HOME/bin/* # Copy examples to Apex user area -RUN cp -pr ${POLICY_HOME}/examples /home/apexuser \ +RUN cp -pr $POLICY_HOME/examples /home/apexuser \ && chown -R apexuser:apexuser /home/apexuser/* USER apexuser -ENV PATH ${POLICY_HOME}/bin:$PATH +ENV PATH $POLICY_HOME/bin:$PATH WORKDIR /home/apexuser diff --git a/packages/apex-pdp-package-full/pom.xml b/packages/apex-pdp-package-full/pom.xml index d0a2c15bc..a3b6d3fbf 100644 --- a/packages/apex-pdp-package-full/pom.xml +++ b/packages/apex-pdp-package-full/pom.xml @@ -2,6 +2,7 @@ ============LICENSE_START======================================================= Copyright (C) 2018 Ericsson. All rights reserved. Modifications Copyright (C) 2019 Nordix Foundation + 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. @@ -514,6 +515,7 @@ <descriptor>src/main/package/tarball/assembly.xml</descriptor> </descriptors> <finalName>${project.artifactId}-${project.version}</finalName> + <appendAssemblyId>false</appendAssemblyId> </configuration> </execution> </executions> @@ -526,7 +528,7 @@ <configuration> <tasks> <untar - src="${project.build.directory}/${project.artifactId}-${project.version}-tarball.tar.gz" + src="${project.build.directory}/${project.artifactId}-${project.version}.tar.gz" dest="${project.build.directory}/install_hierarchy" compression="gzip" /> </tasks> </configuration> diff --git a/packages/pom.xml b/packages/pom.xml index 9a5c41a38..2fbf5ad0b 100644 --- a/packages/pom.xml +++ b/packages/pom.xml @@ -1,6 +1,7 @@ <!-- ============LICENSE_START======================================================= Copyright (C) 2018 Ericsson. 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. @@ -32,11 +33,6 @@ <name>${project.artifactId}</name> <description>[${project.parent.artifactId}] packaging</description> - <modules> - <module>apex-pdp-package-full</module> - <module>apex-pdp-docker</module> - </modules> - <profiles> <profile> <id>apexSite</id> @@ -52,5 +48,22 @@ </site> </distributionManagement> </profile> + <profile> + <id>default</id> + <activation> + <activeByDefault>true</activeByDefault> + </activation> + </profile> + <profile> + <id>docker</id> + <modules> + <module>apex-pdp-package-full</module> + <module>apex-pdp-docker</module> + </modules> + <properties> + <docker.skip.push>false</docker.skip.push> + </properties> + </profile> + </profiles> </project> |