Skip to content

Instantly share code, notes, and snippets.

@jdmwood
Created June 26, 2019 15:10
Show Gist options
  • Save jdmwood/495d5f63daaa2c48fa4d97d64bc45064 to your computer and use it in GitHub Desktop.
Save jdmwood/495d5f63daaa2c48fa4d97d64bc45064 to your computer and use it in GitHub Desktop.
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.27.2</version>
<configuration>
<images>
<image>
<alias>my-service</alias>
<name>my-service</name>
<build>
<from>(some image)</from>
<tags>
<tag>latest</tag>
</tags>
<assembly>
<inline>
<fileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>${project.build.finalName}.jar</include>
</includes>
</fileSet>
</fileSets>
</inline>
</assembly>
</build>
<run>
<entrypoint>
<exec>
<arg>java</arg>
<!-- Use Jacoco coverage agent, and dump on exit -->
<arg>-javaagent:/jacoco-it/jacoco-agent.jar=output=file,append=false,dumponexit=true,destfile=/jacoco-it/jacoco-it.exec</arg>
<arg>-jar</arg>
<arg>maven/${project.build.finalName}.jar</arg>
</exec>
</entrypoint>
<ports>
<port>8080:8080</port>
</ports>
<wait>
<!-- The plugin waits until this URL is reachable via HTTP ... -->
<http>
<url>http://${docker.host.address}:8080</url>
</http>
<kill>60000</kill> <!-- Allow Jacoco enough time to dump on shutdown -->
</wait>
<volumes>
<bind>
<!-- Share a local directory -->
<volume>${project.build.directory}/jacoco-it:/jacoco-it</volume>
</bind>
</volumes>
</run>
</image>
</images>
</configuration>
<executions>
<execution>
<id>build</id>
<phase>package</phase>
<goals>
<goal>build</goal>
</goals>
</execution>
<!-- Start/stop the container before/after integration tests -->
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment