spotify / docker-maven-plugin

INACTIVE: A maven plugin for Docker
Apache License 2.0
2.66k stars 575 forks source link

Building multiple images from different dockerfiles #335

Closed darrylb-github closed 6 years ago

darrylb-github commented 7 years ago

Description

I have two Dockerfiles I want to build as part of mvn docker:build. They are located in a sub dir with a layout like so:

- pom.xml
- docker/
-- image1/
--- Dockerfile
-- image2/
--- Dockerfile

When running mvn docker:build I want it to build two images - one for each dockerfile.

How to reproduce

Simplified example:

            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <version>0.4.13</version>

                <executions>
                    <execution>
                        <id>image1</id>
                        <goals>
                            <goal>build</goal>
                        </goals>
                        <configuration>
                            <imageName>image1</imageName>
                            <dockerDirectory>docker/image1</dockerDirectory>
                            <imageTags>
                                <imageTag>${project.version}</imageTag>
                                <imageTag>latest</imageTag>
                            </imageTags>
                        </configuration>
                    </execution>

                    <execution>
                        <id>image2</id>
                        <goals>
                            <goal>build</goal>
                        </goals>
                        <configuration>
                            <imageName>image2</imageName>
                            <dockerDirectory>docker/image2</dockerDirectory>
                            <imageTags>
                                <imageTag>${project.version}</imageTag>
                                <imageTag>latest</imageTag>
                            </imageTags>
                        </configuration>
                    </execution>
                </executions>

            </plugin>

What do you expect

I expect it to build two images (image1 and image2) using the two different dockerfiles (docker/image1/Dockerfile and docker/image2/Dockerfile).

What happened instead

Exception caught: Must specify baseImage if dockerDirectory is null

It expects configuration outside of the executions and if I do this for one image and leave the other in the executions, it doesn't execute both - only the one outside executions.

Should this be possible? Any other ways to do this? I can include multiple plugin definitions but maven warns about them being duplicated: [WARNING] 'build.plugins.plugin.(groupId:artifactId)' must be unique but found duplicate declaration of plugin com.spotify:docker-maven-plugin

Software:

mqasimsarfraz commented 7 years ago

Is there any update on this? I am looking for similar functionality.

mattnworb commented 7 years ago

I think this is because there is a default execution of docker:build added to the package phase, if you name one of your <executions> with <id>default</id> then I believe it would be supplying the configuration for the default execution.

xetra11 commented 6 years ago

Any news on this?

sokomishalov commented 6 years ago

+1

zh32 commented 6 years ago

:+1:

fidesachates commented 6 years ago

+1

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

priteshkadavrean commented 3 years ago

+1