Add docker image building to maven configuration
authorPawel <pawel.kasperkiewicz@nokia.com>
Mon, 10 Feb 2020 12:03:38 +0000 (13:03 +0100)
committerPawel <pawel.kasperkiewicz@nokia.com>
Mon, 10 Feb 2020 14:40:41 +0000 (15:40 +0100)
Issue-ID: AAF-995
Signed-off-by: Pawel <pawel.kasperkiewicz@nokia.com>
Change-Id: I26862c9f2597ff058f869320ebd3948030b63051

certService/README.md
certService/pom.xml

index 431ff1d..908cfa2 100644 (file)
 
     ```
     
-### Building Docker image
+### Building Docker image manually
     ```
     docker build -t cert-service .
 
     ```
+    
+### Install the package into the local repository
+    ```
+    mvn clean install
+   
+    ```     
+    
+### Building Docker image and  install the package into the local repository
+    ```
+    mvn clean install -P docker
+   
+    ```   
 
 ### Running Docker container
     ```
index b3b83de..8402d74 100644 (file)
@@ -38,6 +38,7 @@
         <spring-boot-starter-actuator.version>2.2.4.RELEASE</spring-boot-starter-actuator.version>
         <spring-boot-starter-log4j2.version>2.1.5.RELEASE</spring-boot-starter-log4j2.version>
         <springdoc-openapi-ui.version>1.2.21</springdoc-openapi-ui.version>
+        <docker-maven-plugin.version>0.33.0</docker-maven-plugin.version>
     </properties>
 
     <dependencyManagement>
                     <quiet>true</quiet>
                     <verbose>false</verbose>
                     <useStandardDocletOptions>false</useStandardDocletOptions>
+                    <javadocExecutable>${java.home}/bin/javadoc</javadocExecutable>
                 </configuration>
                 <executions>
                     <execution>
         </plugins>
     </build>
 
+    <profiles>
+        <profile>
+            <id>docker</id>
+            <activation>
+                <activeByDefault>false</activeByDefault>
+            </activation>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>io.fabric8</groupId>
+                        <artifactId>docker-maven-plugin</artifactId>
+                        <version>${docker-maven-plugin.version}</version>
+                        <executions>
+                            <execution>
+                                <id>start</id>
+                                <phase>pre-integration-test</phase>
+                                <goals>
+                                    <goal>build</goal>
+                                    <goal>start</goal>
+                                </goals>
+                            </execution>
+                            <execution>
+                                <id>stop</id>
+                                <phase>post-integration-test</phase>
+                                <goals>
+                                    <goal>stop</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                        <configuration>
+                            <images>
+                                <image>
+                                    <name>cert-service</name>
+                                    <build>
+                                        <dockerFile>${project.basedir}/Dockerfile</dockerFile >
+                                    </build>
+                                    <run>
+                                        <ports>
+                                            <port>8080:8080</port>
+                                        </ports>
+                                        <wait>
+                                            <!-- Check for this URL to return a 200 return code .... -->
+                                            <url>http://localhost:8080/actuator/health</url>
+                                            <time>120000</time>
+                                        </wait>
+                                    </run>
+                                </image>
+                            </images>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
 </project>