Skip to content

Instantly share code, notes, and snippets.

@derekbassett
Last active October 20, 2017 18:42
Show Gist options
  • Save derekbassett/ef9791cf14285465efa0c865be1d2bbd to your computer and use it in GitHub Desktop.
Save derekbassett/ef9791cf14285465efa0c865be1d2bbd to your computer and use it in GitHub Desktop.
Using com.spotify:dockerfile-maven-plugin with multi-project poms.
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<configuration>
<repository>${docker.registry}/${docker.image}</repository>
<tag>${docker.tag}</tag>
<buildArgs>
<JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
</buildArgs>
<skip>${dockerfile.skip}</skip>
</configuration>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
<goal>push</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<version>1.3.6</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
@derekbassett
Copy link
Author

derekbassett commented Oct 20, 2017

We have a multi-pom project which has a sub-project that wants to build a docker image.
We want to be able to call mvn dockerfile:build dockerfile:push on the parent pom and get it to build and push all docker images built in the child poms.
Here is the solution we came up with.
This allows us at the top level of the pom call mvn dockerfile:build to build all our children docker images, and at our top level mvn dockerfile.skip=true deploy will skip generating docker images in the deploy phase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment