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

JIB image build is failing if a Dockerfile is located in the root folder of the project. #970

Open
sunix opened this issue Oct 4, 2021 · 4 comments
Milestone

Comments

@sunix
Copy link
Member

sunix commented Oct 4, 2021

Description

As a user, I would like to use the jib build strategy and not the default docker one. So when I am invoking:

mvn k8s:build  -Djkube.build.strategy=jib

It should use the jib strategy.

However if a Dockerfile is located in the root folder of the project, the error is raised:

[ERROR] Failed to execute goal org.eclipse.jkube:kubernetes-maven-plugin:1.4.0:build (default-cli) on project live-stream-question: Failed to execute the build: Error when building JIB image: Dockerfile mode is not supported with JIB build strategy -> [Help 1]

Selection_524

Info

  • Eclipse JKube version : 1.4.0

  • Maven version (mvn -v) : 3.8.1 and 3.6.3

  • Kubernetes / Red Hat OpenShift setup and version : N/A

  • If it's a bug, how to reproduce :

    1. Clone https://github.com/parisjug/live-stream-question
    2. add JKube to the pom.xml
       <plugin>
         <groupId>org.eclipse.jkube</groupId>
         <artifactId>kubernetes-maven-plugin</artifactId>
         <version>1.4.0</version>
       </plugin>
      
    3. run mvn k8s:build -Djkube.build.strategy=jib
    4. See the error above
  • Sample Reproducer Project : https://github.com/parisjug/live-stream-question

@manusa
Copy link
Member

manusa commented Oct 4, 2021

There's a collision in mode detection here.

The Dockerfile in the root directory makes JKube assume we are running in Simple Dockerfile mode.

JIB build strategy is not compatible with (any of) the Dockerfile mode(s).

I'm not sure what the right approach here can be.

Some ideas:

  • Extra-flag to bypass Dockerfile mode, user who wants to build this project with Jib (and go into another mode) should provide both flags. This allows the project to be built with Jib regardless of the directory structure.
  • Additional warning and fall-back to next mode. This is dangerous, since the final image will be different depending on the build strategy and many users might not notice.
  • Work in a way to parse the Dockerfile and convert it to a Jib configuration.
  • ...

@sunix
Copy link
Member Author

sunix commented Oct 5, 2021

My suggestion is avoid failure when possible: if the user is requesting the JIB build strategy, we have to obey and build with JIB even if the Dockerfile is not used.

It may be good to add a kind of summary at the end of the build. Something like:

[INFO] k8s:  /home/sunix/github/parisjug/live-stream-question/target/docker/java/live-stream-question/1.0.0/tmp/docker-build.tar successfully built
[INFO] k8s:  Docker image built with JIB strategy
[WARN] k8s:  Dockerfile detected but ignored as Dockerfile mode is not supported with JIB build strategy
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  16.411 s
[INFO] Finished at: 2021-10-05T09:36:45+02:00
[INFO] ------------------------------------------------------------------------

@manusa
Copy link
Member

manusa commented Oct 5, 2021

Yes, but the user might be assuming that JKube is operationg in Dockerfile mode, and it's not, which will lead them to unexpected (and maybe unpleasant) results. Thus we might want the user to opt-in to said way of working by forcing them to provide an extra-flag.

Your proposal aligns with my second suggestion "Additional warning and fall-back to next mode....", but as I say there, I find this very dangerous. We can further discuss this during triage session.

@manusa
Copy link
Member

manusa commented Oct 18, 2021

As agreed during triage meeting:

  • Create an additional flag (something like jkube.ignore-docker-file-mode)
    • flag is false by default
    • when flag is enabled, JKube bypasses the simple dockerfile and dockerfile modes
    • when the flag is enabled, log a warning stating that the Dockerfile mdoe is ignored
  • When the Dockerfile mode is detected and a Jib build strategy is configured by the user: Instead of showing an error, show an error with the suggested opt-out strategy. (Something like "Jib build strategy is not compatible with Dockefile mode, you can bypass the Dockerfile mode by providing -Djkube.ignore-docker-file-mode)

@manusa manusa added this to the 1.6.0 milestone Oct 18, 2021
@manusa manusa modified the milestones: 1.6.0, 1.7.0 Feb 3, 2022
@manusa manusa modified the milestones: 1.7.0, 1.x Feb 25, 2022
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