DEV Community

Discussion on: How to create a production Docker image

abdorah profile image
Kotbi Abderrahmane Author

That's in fact a very good option for doing this. But I wanted to show also multiple stages building in docker.

donut87 profile image
Christian Baer

An easy and solid way to do so, would be to use 2 different containers for building and deploying.
You build with a mvn container and copy only the .war file to the production container. This covers two aspects. First and foremost, the production docker image is much much smaller (no mvn, no compile logs, no other clutter) and second you can show the multi stage build.
Then use docker-compose, kubernetes or something of the like to start up your environment.