spotify / dockerfile-maven

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

Should dockerfile be child of the `contextDirectory`? #336

Closed jcchavezs closed 4 years ago

jcchavezs commented 4 years ago

FEATURE REQUEST:

Description

Relax the condition where dockerfile should be a child element of contextDirectory: https://github.com/spotify/dockerfile-maven/blob/15780af5df74e337fa4f67d564585b1ad7a9b47e/plugin/src/main/java/com/spotify/plugin/dockerfile/BuildMojo.java#L282. This is not an ideal restriction as for example docker-compose allows to have something like:

  myapp:
    build:
      context: ./path
      dockerfile: ../Dockerfile

How to reproduce

<plugin>
                    <groupId>com.spotify</groupId>
                    <artifactId>dockerfile-maven-plugin</artifactId>
                    <version>1.4.13</version>
                    <executions>
                        <execution>
                            <id>default-cli</id>
                            <goals>
                                <goal>build</goal>
                                <goal>push</goal>
                            </goals>
                        </execution>
                    </executions>
                    <configuration>
                        <repository>${dockerfile.registryUrl}/library/${project.artifactId}</repository>
                        <tag>${git.commit.id}</tag>
                        <contextDirectory>${project.parent.basedir}/${project.name}</contextDirectory>
                        <dockerfile>${project.parent.basedir}/Dockerfile</dockerfile>
                        <buildArgs>
                            <APP_NAME>${project.name}</APP_NAME>
                        </buildArgs>
                        <useMavenSettingsForAuth>true</useMavenSettingsForAuth>
                        <googleContainerRegistryEnabled>false</googleContainerRegistryEnabled>
                        <noCache>true</noCache>
                    </configuration>
                </plugin>

What do you expect

Accept any location for dockerfile

What happened instead

Shows an error if it is not a child file

I can come up with a PR for this.

Tychom commented 4 years ago

Not only is this possible in docker-compose but also with docker build:

docker build -f ../Dockerfile ./path

So this restriction seems unnecessary.

cr-kobyisrael commented 4 years ago

I also think this should be supported. It's already solved in docker repo and needs to be added here as well. see: https://github.com/docker/cli/pull/886

stale[bot] commented 4 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.

jcchavezs commented 4 years ago

Interesting how this issue is marked as stale even when no maintainers have given feedback or had a look at it.

stale[bot] commented 4 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.

jcchavezs commented 4 years ago

Does it make sense to accept issues on this repo if a bot is going to close them with no involvement from maintainers?

stodge commented 4 years ago

Being able to specify a path to a dockerfile makes sense to me: <dockerfile>${project.parent.basedir}/Dockerfile</dockerfile>. The assumption that the Dockerfile is in the context is too rigid.

But after 9 months I won't hold my breath. I'll have to look for another Maven plugin. Any suggestions?