Configure maven to build docker image

Issue-ID: INT-1896
Signed-off-by: Grzegorz Wielgosinski <g.wielgosins@samsung.com>
Change-Id: Id0d201b26bc946af6cd0af34714fb912e2aef77f
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100644
index 0000000..08bb20f
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,16 @@
+FROM nexus3.onap.org:10001/onap/integration-java11:8.0.0
+
+COPY --chown=onap:onap a1-pe-simulator*.jar /a1-pe-simulator/a1-pe-simulator.jar
+
+# Create conf directory where vnf.config and topology files will be placed by ONAP controller
+USER root
+RUN mkdir /var/netconf2 && chown onap:onap /var/netconf2
+USER onap
+
+COPY --chown=onap:onap resource/* /var/netconf2/
+
+WORKDIR /a1-pe-simulator
+
+EXPOSE 9998
+
+ENTRYPOINT exec java $JAVA_SEC_OPTS $JAVA_OPTS -Djava.security.egd=file:/dev/urandom -Duser.home=/a1-pe-simulator -Dproc.name=a1-pe-simulator -jar a1-pe-simulator.jar
diff --git a/pom.xml b/pom.xml
index fabb4fd..1e9db85 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,6 +90,13 @@
 
     <properties>
         <java.version>11</java.version>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format>
+        <skipDockerPush>true</skipDockerPush>
+        <docker.registry>nexus3.onap.org:10003</docker.registry>
+        <docker-maven-plugin.version>0.31.0</docker-maven-plugin.version>
+        <docker-image.namespace>onap</docker-image.namespace>
+        <docker-image.name.prefix>org.onap.a1pesimulator</docker-image.name.prefix>
     </properties>
 
     <build>
@@ -163,7 +170,39 @@
                     </execution>
                 </executions>
             </plugin>
+            <plugin>
+                <groupId>io.fabric8</groupId>
+                <artifactId>docker-maven-plugin</artifactId>
+                <version>${docker-maven-plugin.version}</version>
+                <executions>
+                    <execution>
+                        <id>docker-build-image</id>
+                        <phase>package</phase>
+                        <goals>
+                            <goal>build</goal>
+                            <goal>push</goal>
+                        </goals>
+                    </execution>
+                </executions>
+                <configuration>
+                    <skipPush>${skipDockerPush}</skipPush>
+                    <verbose>true</verbose>
+                    <imagePullPolicy>IfNotPresent</imagePullPolicy>
+                    <images>
+                        <image>
+                            <name>${docker-image.namespace}/${docker-image.name.prefix}.${project.artifactId}</name>
+                            <registry>${docker.registry}</registry>
+                            <build>
+                                <tags>
+                                    <tag>${project.version}-${maven.build.timestamp}Z</tag>
+                                </tags>
+                            </build>
+                        </image>
+                    </images>
+                </configuration>
+            </plugin>
         </plugins>
     </build>
 
 </project>
+