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

Quarkus should recommend multi-stage builds for docker builds #2814

Closed
erkanerol opened this issue Jun 12, 2019 · 5 comments
Closed

Quarkus should recommend multi-stage builds for docker builds #2814

erkanerol opened this issue Jun 12, 2019 · 5 comments

Comments

@erkanerol
Copy link

Description

Hi Quarkus team. Nowadays I am taking a look at Quarkus and trying to implement a small app. First of all, thanks a lot for this great work! Developer experience is really king with this framework.

When I checked the Dockerfiles in Quarkus projects, I saw that Dockerfiles are not self-contained. We need to run mvn/gradle to create runnable JAR files or native binaries at first and then we can run docker build commands. Also, maven runs docker run to create native binaries from runnable jar files.

I think this is not a good way. Here are my arguments.

  • It is not elegant. It doesn't fit the philosophy "Developer experience is king."
  • It is against 12 factor app. Jar files are created in local machines and the configuration of local machine may affect the build process. The process should be immutable. See dockerBuild for native image doesn't work with remote Docker daemons #1610
  • It may a problem in modern CI/CD tools. Many CI/CD tools let you run some commands inside docker containers. You can run mvn inside a docker container but you are not allowed to run another container via a process in the container.

Implementation ideas

If Quarkus is a modern, cloud-native framework, I believe it should use multi-stage builds and isolate build processes from host machines.

I have prepared an example here: https://github.com/erkanerol/quarkus-multistage-docker-build

@erkanerol erkanerol added the kind/enhancement New feature or request label Jun 12, 2019
@loicmathieu
Copy link
Contributor

Hello,

I second this, I use a multistage build for my Quarkus demo apps that I use in blog/presentation of Quarkus, you can find my version here : https://github.com/loicmathieu/quarkus-demo/blob/master/src/main/docker/Dockerfile

There is an existing maven-with-Grall image that can be used provided by the Quarkus Team so my version is simpler that yours ;)

I planned to propose a doc upate to include this third way of building a Quarkus application for some times but didn't find the time to do it yet ...

@erkanerol
Copy link
Author

The section is added into the guide. Thanks a lot!

https://quarkus.io/guides/building-native-image-guide#creating-a-container-with-a-multi-stage-docker-build

@andreas-eberle
Copy link
Contributor

Can you add a gradle version of this guide as well?

@stefanoturri
Copy link

+1 for having guide for multi-stage docker builds also for gradle

@gilliardmacedo
Copy link

Thanks a lot for this!

When using multi stage docker build, remember to edit .dockerignore to include sources!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants