This repository shows how to dockerize a quarkus project without running maven in local machine. It shows that using multi-stage builds is a better alternative.
Here is the related issue: quarkusio/quarkus#2814
Here are the alternative dockerfiles.
- Run mvn to create JAR file
./mvnw package
- Run docker to build an image with the created JAR file
docker build -f Dockerfile.jvm -t quarkus-quickstart/getting-started-jvm .
- Run a container with the image
docker run -i --rm -p 8080:8080 quarkus-quickstart/getting-started-jvm:latest
- Run mvn to create JAR file and then to run a docker container to create native binary
./mvnw package -Pnative -Dnative-image.docker-build=true
For
native
profile, mvn runs a docker image to create a native binary from JAR file. I believe runningdocker run
via mvn is not a good idea.
- Run docker to build an image with the created JAR file
docker build -f Dockerfile.native -t quarkus-quickstart/getting-started-native .
- Run a container with the image
docker run -i --rm -p 8080:8080 quarkus-quickstart/getting-started-native:latest
- Run docker to build an image with runnable JAR
docker build -f Dockerfile.proposed.jvm -t quarkus-quickstart/getting-started-proposed-jvm .
- Run a container with the image
docker run -i --rm -p 8080:8080 quarkus-quickstart/getting-started-proposed-jvm:latest
- Run docker to build an image with native binary
docker build -f Dockerfile.proposed.native -t quarkus-quickstart/getting-started-proposed-native .
- Run a container with the image
docker run -i --rm -p 8080:8080 quarkus-quickstart/getting-started-proposed-native:latest