From the docs https://github.com/spotify/dockerfile-maven, it says:
For example, a docker-compose.yml might look like:
service-a:
build: a/
ports:
- '80'
service-b:
build: b/
links:
- service-a
Now, docker-compose up and docker-compose build will work as expected.
But how to write the pom.xml
file, still like as if not using compose? Set the goal to be "build"?
<plugin>
<groupId>com.spotify</groupId>
<artifactId>dockerfile-maven-plugin</artifactId>
<executions>
<execution>
<id>default</id>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
You cannot build the images starting from a docker-compose.yml file using the spotify plugin. The readme mentions that the design goal was:
That section of the docs you quoted actually says that on a maven multi-module project structure one can easily use other build tools such as
docker-compose
.Nevertheless, there are ways to build with maven from a
docker-compose.yml
. One is with the maven-execFor the file in question:
the relevant part of the
pom.xml
would be something like the following:Another solution is to use fabric8
Use the one that suits you best.