aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohammadreza Pasandideh <mohammadreza.pasandideh@amdocs.com>2018-08-16 16:33:38 -0400
committerMohammadreza Pasandideh <mohammadreza.pasandideh@amdocs.com>2018-08-17 13:48:59 -0400
commitd072a72499ec16f08af206758633dd362747fe08 (patch)
tree497933e02ac7fcdb526db8654e20a0d65facc775
parentfccfe14bac462212fac43b8f134678eb48144ac5 (diff)
Docker file: Network Discovery Context Builder
Issue-ID: LOG-401 Change-Id: Icfe89647bf7de5bc398dcd0aedd2bb6ec228833a Signed-off-by: Mohammadreza Pasandideh <mohammadreza.pasandideh@amdocs.com>
-rw-r--r--pom.xml238
-rw-r--r--src/main/docker/Dockerfile19
-rw-r--r--src/main/docker/startService.sh8
3 files changed, 200 insertions, 65 deletions
diff --git a/pom.xml b/pom.xml
index d144886..a4bac88 100644
--- a/pom.xml
+++ b/pom.xml
@@ -34,6 +34,9 @@ limitations under the License.
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<swagger.directory>${project.build.directory}/generated-resources/swagger</swagger.directory>
+ <!--docker -->
+ <docker.tag>${project.version}-${timestamp}</docker.tag>
+ <docker.latest.tag>${project.version}-latest</docker.latest.tag>
</properties>
<dependencyManagement>
@@ -151,71 +154,9 @@ limitations under the License.
</dependencies>
<build>
- <finalName>network-discovery</finalName>
+ <finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
- <groupId>com.github.kongchen</groupId>
- <artifactId>swagger-maven-plugin</artifactId>
- <version>3.1.7</version>
- <configuration>
- <apiSources>
- <apiSource>
- <locations>
- <location>org.onap.pomba.contextbuilder.networkdiscovery.service.rs</location>
- </locations>
- <basePath>/network-discovery</basePath>
- <info>
- <title>Network Discovery API</title>
- <version>${project.version}</version>
- <termsOfService>http://onap.org</termsOfService>
- <contact>
- <name>Sharon Chisholm</name>
- <email>sharon.chisholm@amdocs.com</email>
- </contact>
- </info>
- <securityDefinitions>
- <securityDefinition>
- <name>basicAuth</name>
- <type>basic</type>
- </securityDefinition>
- </securityDefinitions>
- <swaggerDirectory>${swagger.directory}</swaggerDirectory>
- </apiSource>
- </apiSources>
- </configuration>
- <executions>
- <execution>
- <phase>compile</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <artifactId>maven-resources-plugin</artifactId>
- <version>3.1.0</version>
- <executions>
- <execution>
- <id>copy-resources</id>
- <!-- here the phase you need -->
- <phase>prepare-package</phase>
- <goals>
- <goal>copy-resources</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.outputDirectory}</outputDirectory>
- <resources>
- <resource>
- <directory>${swagger.directory}</directory>
- <targetPath>META-INF/resources/swagger</targetPath>
- </resource>
- </resources>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<executions>
@@ -227,8 +168,6 @@ limitations under the License.
</executions>
</plugin>
</plugins>
- <!-- mention the logback.xml location through system property or environment variable to edit logback.xml at run
- time -->
<resources>
<resource>
<directory>src/main/resources</directory>
@@ -239,4 +178,173 @@ limitations under the License.
</resource>
</resources>
</build>
+
+ <profiles>
+ <profile>
+ <id>docker</id>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>io.fabric8</groupId>
+ <artifactId>docker-maven-plugin</artifactId>
+ <version>0.19.1</version>
+ <configuration>
+ <verbose>true</verbose>
+ <apiVersion>1.23</apiVersion>
+ <images>
+ <image>
+ <name>onap/${project.artifactId}</name>
+ <alias>${project.artifactId}</alias>
+ <build>
+ <cleanup>try</cleanup>
+ <dockerFileDir>${project.basedir}/target/docker-stage</dockerFileDir>
+ <tags>
+ <tag>${docker.snapshot.tag}</tag>
+ <tag>${docker.latest.tag}</tag>
+ </tags>
+ </build>
+ </image>
+ </images>
+ </configuration>
+ <executions>
+ <execution>
+ <id>generate-images</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>build</goal>
+ </goals>
+ </execution>
+ <execution>
+ <id>push-images</id>
+ <phase>deploy</phase>
+ <goals>
+ <goal>build</goal>
+ <goal>push</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>com.github.kongchen</groupId>
+ <artifactId>swagger-maven-plugin</artifactId>
+ <version>3.1.7</version>
+ <configuration>
+ <apiSources>
+ <apiSource>
+ <locations>
+ <location>org.onap.pomba.contextbuilder.networkdiscovery.service.rs</location>
+ </locations>
+ <basePath>/{${project.artifactId}</basePath>
+ <info>
+ <title>Network Discovery Context Builder API</title>
+ <version>${project.version}</version>
+ <termsOfService>http://onap.org</termsOfService>
+ </info>
+ <securityDefinitions>
+ <securityDefinition>
+ <name>basicAuth</name>
+ <type>basic</type>
+ </securityDefinition>
+ </securityDefinitions>
+ <swaggerDirectory>${swagger.directory}</swaggerDirectory>
+ </apiSource>
+ </apiSources>
+ </configuration>
+ <executions>
+ <execution>
+ <phase>compile</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <artifactId>maven-resources-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>copy-dockerfile</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals><!-- here the phase you need -->
+ <phase>package</phase>
+ <configuration>
+ <outputDirectory>${project.basedir}/target/docker-stage</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/docker</directory>
+ <includes>
+ <include>Dockerfile</include>
+ </includes>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-properties</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <outputDirectory>${project.basedir}/target/docker-stage/config</outputDirectory>
+ <resources>
+ <resource>
+ <directory>config</directory>
+ <includes>
+ <include>*.properties</include>
+ <include>*.xml</include>
+ </includes>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-script</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <outputDirectory>${project.basedir}/target/docker-stage/</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/docker</directory>
+ <includes>
+ <include>*.sh</include>
+ </includes>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ <execution>
+ <id>copy-jar</id>
+ <goals>
+ <goal>copy-resources</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <outputDirectory>${project.basedir}/target/docker-stage/</outputDirectory>
+ <resources>
+ <resource>
+ <directory>target</directory>
+ <includes>
+ <include>*.jar</include>
+ </includes>
+ <filtering>false</filtering>
+ </resource>
+ </resources>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
</project>
diff --git a/src/main/docker/Dockerfile b/src/main/docker/Dockerfile
new file mode 100644
index 0000000..9963da1
--- /dev/null
+++ b/src/main/docker/Dockerfile
@@ -0,0 +1,19 @@
+FROM anapsix/alpine-java:jre8
+
+ARG MICROSERVICE_HOME=/opt/app/
+
+# Build up the deployment folder structure
+RUN mkdir -p $MICROSERVICE_HOME
+RUN mkdir -p $MICROSERVICE_HOME/config/
+RUN mkdir -p $MICROSERVICE_HOME/lib/
+RUN mkdir -p $MICROSERVICE_HOME/bin/
+
+ADD pomba-network-discovery-context-builder.jar $MICROSERVICE_HOME/lib/
+ADD startService.sh $MICROSERVICE_HOME/bin/
+COPY config/ $MICROSERVICE_HOME/config/
+
+RUN chmod 755 $MICROSERVICE_HOME/config/*
+RUN chmod 755 $MICROSERVICE_HOME/lib/*
+RUN chmod 755 $MICROSERVICE_HOME/bin/*
+
+CMD ["/opt/app/bin/startService.sh"] \ No newline at end of file
diff --git a/src/main/docker/startService.sh b/src/main/docker/startService.sh
new file mode 100644
index 0000000..7cc6952
--- /dev/null
+++ b/src/main/docker/startService.sh
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+cd /opt/app
+if [ -z "${java_runtime_arguments}" ]; then
+ java -Dlogging.config=config/logback.xml -Xms128m -Xmx512m -jar /opt/app/lib/pomba-network-discovery-context-builder.jar
+else
+ java -Dlogging.config=config/logback.xml $java_runtime_arguments -jar /opt/app/lib/pomba-network-discovery-context-builder.jar
+fi \ No newline at end of file