spotify / dockerfile-maven

MATURE: A set of Maven tools for dealing with Dockerfiles
Apache License 2.0
2.75k stars 493 forks source link

[Question] How to push the docker image with different tags to multiple registries when deploying #392

Open shink opened 2 years ago

shink commented 2 years ago

Hi, there! Thank you for your contributions first!

I just have an question. How to push the docker image with different tags to multiple registries when deploying? I just want push it to Docker Hub and GitHub Container together.

Thank you very much.

fishermans commented 2 years ago

Hi @shink,

Without warranty (not tested): I guess you have to use multiple executable configurations within the executables tag of your plugin config. Move the configuration into each as usual.

            <plugin>
                <groupId>com.spotify</groupId>
                <artifactId>dockerfile-maven-plugin</artifactId>
                <version>1.14.13</version>
                <executions>
                    <execution>
                        <id>default</id>
                        <goals>
                            <goal>build</goal>
                            <goal>push</goal>
                        </goals>
                        <configuration>
                            <repository>spotify/foobar</repository>
                            <tag>${project.version}</tag>
                            <buildArgs>
                                <JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
                            </buildArgs>
                        </configuration>
                    </execution>                    
                    <execution>
                        <id>second</id>
                        <goals>
                            <goal>build</goal>
                            <goal>push</goal>
                        </goals>
                        <phase>install</phase>
                        <configuration>
                            <repository>foo/bar</repository>
                            <tag>bar</tag>
                            <buildArgs>
                                <JAR_FILE>${project.build.finalName}.jar</JAR_FILE>
                            </buildArgs>
                        </configuration>
                    </execution>
                </executions>
            </plugin>