Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong docker file being used with multiple images created. #361

Closed
philnate opened this issue Jan 6, 2016 · 4 comments
Closed

Wrong docker file being used with multiple images created. #361

philnate opened this issue Jan 6, 2016 · 4 comments

Comments

@philnate
Copy link

philnate commented Jan 6, 2016

Hi,

we have an issue with the plugin pulling in wrong Dockerfiles. We create a base image within the default profile, which is later on used within -P docker profile for other images. But somehow the first image within the docker profile will be created using the parent image Dockerfile rather than it's own. Adding an empty to the list seems to cure this behaviour. Version used is 0.13.7

    <build>
        <plugins>
            <plugin>
                <groupId>org.jolokia</groupId>
                <artifactId>docker-maven-plugin</artifactId>
                <configuration>
                <skipTags>true</skipTags>
                <logDate>default</logDate>
                <images>
                    <image>
                        <alias>base</alias>
                        <name>registry/base</name>
                        <build>
                            <assembly>
                                <dockerFileDir>jre</dockerFileDir>
                            </assembly>
                        </build>
                    </image>
                </images>
                </configuration>
                <executions>
                    <execution>
                        <id>build-images</id>
                        <phase>package</phase>
                        <goals>
                            <goal>build</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>docker</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.jolokia</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <configuration>
                            <skipTags>true</skipTags>
                            <logDate>default</logDate>
                            <images>
                                <!--add this to fix the issue-->
                                <!--<image></image>-->
                                <image>
                                    <name>registry/one</name>
                                    <build>
                                        <from>registry/base</from>
                                        <assembly>
                                            <mode>zip</mode>
                                            <basedir>/opt</basedir>
                                            <descriptor>one.xml</descriptor>
                                        </assembly>
                                        <cmd>
                                            <shell>some shell</shell>
                                        </cmd>
                                    </build>
                                </image>
                                <image>
                                    <name>registry/two</name>
                                    <build>
                                        <from>registry/base</from>
                                        <assembly>
                                            <mode>zip</mode>
                                            <basedir>/opt</basedir>
                                            <descriptor>two.xml</descriptor>
                                        </assembly>
                                        <cmd>
                                            <shell>some shell</shell>
                                        </cmd>
                                    </build>
                                </image>
                            </images>
                        </configuration>
                        <executions>
                            <execution>
                                <id>build-images</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
@jgangemi
Copy link
Collaborator

jgangemi commented Jan 6, 2016

i believe this is the opposite problem described in #360 and using combine.self="override" should fix the problem.

see here: https://maven.apache.org/pom.html under the plugins section.

@philnate
Copy link
Author

philnate commented Jan 6, 2016

@jgangemi that seems to do the trick. Moving the other base image creation into it's own profile seems to work too. But what I don't get is, why does this affect only the first image and not the other one as well? Assuming that all nodes are merged together (index wise), this means that the base config gets merged into the first image of docker profile. And

<assembly>
             <dockerFileDir>jre</dockerFileDir>
</assembly>

takes precendence over the other configuration. Is this about right?

@jgangemi
Copy link
Collaborator

jgangemi commented Jan 6, 2016

it has something to do w/ the way maven merges the pom configurations but i can't really give a more in-depth explanation then that.

when it does the merge, whatever is missing from the parent gets pulled from the child.

http://blog.sonatype.com/2011/01/maven-how-to-merging-plugin-configuration-in-complex-projects/#.Vo1lD8qEBmM

http://blog.sonatype.com/2007/06/how-to-merge-sub-items-from-parent-pom-to-child-pom-in-a-maven-plugin-configuration-2/#.Vo1lHcqEBmM

@philnate
Copy link
Author

philnate commented Jan 7, 2016

As this is no issue with the plugin, closing the ticket.

@philnate philnate closed this as completed Jan 7, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants