diff options
author | pwielebs <piotr.wielebski@nokia.com> | 2019-07-15 17:25:26 +0200 |
---|---|---|
committer | Piotr Bocheński <piotr.bochenski@nokia.com> | 2019-07-16 12:22:02 +0200 |
commit | b32fb6d7da818acb14a0f4f5f8d3d2a7f7d07da8 (patch) | |
tree | accf44f99f82f09c60c9eae42e4cf1a635d15a9a | |
parent | 80a07b807e248131b5a2c8b2c5b87324f0a2f6ab (diff) |
Align PRH container to new guidelines
Change-Id: I74af532bc6d4ce364c5d8cc2d0ac98386c0df11d
Issue-ID: DCAEGEN2-1648
Signed-off-by: pwielebs <piotr.wielebski@nokia.com>
Signed-off-by: Piotr Bocheński <piotr.bochenski@nokia.com>
-rw-r--r-- | pom.xml | 13 | ||||
-rw-r--r-- | prh-app-server/Dockerfile | 32 | ||||
-rw-r--r-- | prh-app-server/pom.xml | 192 |
3 files changed, 151 insertions, 86 deletions
@@ -97,17 +97,22 @@ <plugin> <groupId>pl.project13.maven</groupId> <artifactId>git-commit-id-plugin</artifactId> - <version>2.2.6</version> + <version>3.0.0</version> + </plugin> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <version>3.0.0</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> - <version>3.1.1</version> + <version>3.1.2</version> </plugin> <plugin> - <groupId>com.spotify</groupId> + <groupId>io.fabric8</groupId> <artifactId>docker-maven-plugin</artifactId> - <version>1.2.0</version> + <version>0.30.0</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> diff --git a/prh-app-server/Dockerfile b/prh-app-server/Dockerfile new file mode 100644 index 00000000..a72ab448 --- /dev/null +++ b/prh-app-server/Dockerfile @@ -0,0 +1,32 @@ +FROM openjdk:8-jre-alpine + +LABEL copyright="Copyright (C) 2018-2019 NOKIA" \ + license.name="The Apache Software License, Version 2.0" \ + license.url="http://www.apache.org/licenses/LICENSE-2.0" \ + maintainer="Nokia Wroclaw ONAP Team" + +RUN adduser -h ${docker.user.dir} -D ${docker.user.name}; \ + chmod -R a+w /var/log + +USER ${docker.user.name} +WORKDIR ${docker.user.dir} + +EXPOSE 8100 8433 +ENTRYPOINT ["java", "-jar", "${project.artifactId}-${project.version}.jar"] + +COPY ${project.build.directory}/${ext.dep.dir.path}/ ${ext.dep.dir.path}/ +COPY ${project.build.directory}/${int.dep.dir.path}/ ${int.dep.dir.path}/ +COPY ${project.build.directory}/${project.artifactId}-${project.version}.jar . + +LABEL git.branch="${git.branch}" \ + git.build.host="${git.build.host}" \ + git.build.time="${git.build.time}" \ + git.build.user.email="${git.build.user.email}" \ + git.build.user.name="${git.build.user.name}" \ + git.build.version="${git.build.version}" \ + git.closest.tag.name="${git.closest.tag.name}" \ + git.commit.id="${git.commit.id}" \ + git.commit.message.short="${git.commit.message.short}" \ + git.commit.time="${git.commit.time}" \ + git.commit.user.email="${git.commit.user.email}" \ + git.commit.user.name="${git.commit.user.name}" diff --git a/prh-app-server/pom.xml b/prh-app-server/pom.xml index 89f25cee..cf33960d 100644 --- a/prh-app-server/pom.xml +++ b/prh-app-server/pom.xml @@ -37,12 +37,14 @@ <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format> <prh.main.class>org.onap.dcaegen2.services.prh.MainApp</prh.main.class> - <dependency.dir.name>libs</dependency.dir.name> - <dependency.dir.location>${project.build.directory}/${dependency.dir.name}</dependency.dir.location> + <classpath.separator>@@</classpath.separator> + <dep.dir.name>libs</dep.dir.name> + <ext.dep.dir.path>${dep.dir.name}/external</ext.dep.dir.path> + <int.dep.dir.path>${dep.dir.name}/internal</int.dep.dir.path> + <skipDocker>false</skipDocker> <docker.user.name>prh</docker.user.name> <docker.user.dir>/home/${docker.user.name}</docker.user.dir> - <docker.image.name>onap/${project.groupId}.${project.artifactId}</docker.image.name> </properties> <build> @@ -71,116 +73,142 @@ </execution> </executions> </plugin> - <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <configuration> - <archive> - <manifest> - <addClasspath>true</addClasspath> - <classpathPrefix>./${dependency.dir.name}/</classpathPrefix> - <useUniqueVersions>false</useUniqueVersions> - <mainClass>${prh.main.class}</mainClass> - <addDefaultImplementationEntries>true</addDefaultImplementationEntries> - </manifest> - <manifestEntries> - <Build-Time>${maven.build.timestamp}</Build-Time> - </manifestEntries> - </archive> - </configuration> - </plugin> + <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <configuration> - <outputDirectory>${dependency.dir.location}</outputDirectory> - <includeScope>runtime</includeScope> <silent>true</silent> + <includeScope>runtime</includeScope> + <pathSeparator>${classpath.separator}</pathSeparator> </configuration> <executions> <execution> <id>copy-external-dependencies</id> - <phase>package</phase> + <phase>prepare-package</phase> <goals> <goal>copy-dependencies</goal> + <goal>build-classpath</goal> </goals> + <configuration> + <excludeGroupIds>${project.parent.groupId}</excludeGroupIds> + <outputDirectory>${project.build.directory}/${ext.dep.dir.path}</outputDirectory> + <prefix>./${ext.dep.dir.path}</prefix> + <outputProperty>classpath.external</outputProperty> + </configuration> </execution> - </executions> - </plugin> - <plugin> - <groupId>com.spotify</groupId> - <artifactId>docker-maven-plugin</artifactId> - <configuration> - <serverId>${onap.nexus.dockerregistry.daily}</serverId> - <imageName>${docker.image.name}</imageName> - <imageTags> - <tag>latest</tag> - </imageTags> - <baseImage>openjdk:${java.version}-jre-alpine</baseImage> - <workdir>${docker.user.dir}</workdir> - <resources> - <resource> - <directory>${dependency.dir.location}</directory> - <targetPath>${dependency.dir.name}</targetPath> - </resource> - <resource> - <directory>${project.build.directory}</directory> - <include>${project.build.finalName}.jar</include> - </resource> - </resources> - <runs> - <run>adduser -h ${docker.user.dir} -D ${docker.user.name}; chmod -R a+w /var/log</run> - </runs> - <exposes> - <expose>8100</expose> - <expose>8433</expose> - </exposes> - <user>${docker.user.name}</user> - <entryPoint>["java", "-jar", "${project.build.finalName}.jar"]</entryPoint> - </configuration> - <executions> <execution> - <id>build-image</id> - <phase>package</phase> + <id>copy-internal-dependencies</id> + <phase>prepare-package</phase> <goals> - <goal>build</goal> + <goal>copy-dependencies</goal> + <goal>build-classpath</goal> </goals> + <configuration> + <includeGroupIds>${project.parent.groupId}</includeGroupIds> + <outputDirectory>${project.build.directory}/${int.dep.dir.path}</outputDirectory> + <prefix>./${int.dep.dir.path}</prefix> + <outputProperty>classpath.internal</outputProperty> + </configuration> </execution> + </executions> + </plugin> + + <plugin> <!-- workaround for MDEP-541 --> + <groupId>org.codehaus.mojo</groupId> + <artifactId>build-helper-maven-plugin</artifactId> + <executions> <execution> - <id>tag-and-push-image-latest</id> - <phase>deploy</phase> + <id>fix-classpath-separator</id> + <phase>prepare-package</phase> <goals> - <goal>tag</goal> + <goal>regex-properties</goal> </goals> <configuration> - <image>${docker.image.name}:latest</image> - <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:latest</newName> - <pushImage>true</pushImage> + <regexPropertySettings> + <regexPropertySetting> + <name>classpath.external</name> + <value>${classpath.external}</value> + <regex>${classpath.separator}</regex> + <replacement xml:space="preserve"> </replacement> + </regexPropertySetting> + <regexPropertySetting> + <name>classpath.internal</name> + <value>${classpath.internal}</value> + <regex>${classpath.separator}</regex> + <replacement xml:space="preserve"> </replacement> + </regexPropertySetting> + </regexPropertySettings> </configuration> </execution> + </executions> + </plugin> + + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-jar-plugin</artifactId> + <configuration> + <archive> + <manifest> + <mainClass>${prh.main.class}</mainClass> + <addDefaultImplementationEntries>true</addDefaultImplementationEntries> + <addBuildEnvironmentEntries>true</addBuildEnvironmentEntries> + <useUniqueVersions>false</useUniqueVersions> <!-- workaround for MJAR-156 --> + </manifest> + <manifestEntries> + <Class-Path>${classpath.external} ${classpath.internal}</Class-Path> + <Git-Branch>${git.branch}</Git-Branch> + <Git-Build-Host>${git.build.host}</Git-Build-Host> + <Git-Build-Time>${git.build.time}</Git-Build-Time> + <Git-Build-User-Email>${git.build.user.email}</Git-Build-User-Email> + <Git-Build-User-Name>${git.build.user.name}</Git-Build-User-Name> + <Git-Build-Version>${git.build.version}</Git-Build-Version> + <Git-Closest-Tag-Name>${git.closest.tag.name}</Git-Closest-Tag-Name> + <Git-Commit-Id>${git.commit.id}</Git-Commit-Id> + <Git-Commit-Message-Short>${git.commit.message.short}</Git-Commit-Message-Short> + <Git-Commit-Time>${git.commit.time}</Git-Commit-Time> + <Git-Commit-User-Email>${git.commit.user.email}</Git-Commit-User-Email> + <Git-Commit-User-Name>${git.commit.user.name}</Git-Commit-User-Name> + </manifestEntries> + </archive> + </configuration> + </plugin> + + <plugin> + <groupId>io.fabric8</groupId> + <artifactId>docker-maven-plugin</artifactId> + <configuration> + <skip>${skipDocker}</skip> + <images> + <image> + <name>${project.groupId}.${project.artifactId}</name> + <registry>${onap.nexus.dockerregistry.daily}</registry> + <build> + <contextDir>${project.basedir}</contextDir> + <cleanup>none</cleanup> + <tags> + <tag>latest</tag> + <tag>${project.version}</tag> + <tag>${project.version}-${maven.build.timestamp}Z</tag> + </tags> + </build> + </image> + </images> + </configuration> + <executions> <execution> - <id>tag-and-push-image-with-version</id> - <phase>deploy</phase> + <id>docker-build-image</id> + <phase>package</phase> <goals> - <goal>tag</goal> + <goal>build</goal> </goals> - <configuration> - <image>${docker.image.name}:latest</image> - <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version}</newName> - <pushImage>true</pushImage> - </configuration> </execution> <execution> - <id>tag-and-push-image-with-version-and-date</id> + <id>docker-push-image</id> <phase>deploy</phase> <goals> - <goal>tag</goal> + <goal>push</goal> </goals> - <configuration> - <image>${docker.image.name}:latest</image> - <newName>${onap.nexus.dockerregistry.daily}/${docker.image.name}:${project.version}-${maven.build.timestamp}Z</newName> - <pushImage>true</pushImage> - </configuration> </execution> </executions> </plugin> |