giros-dit / semantic-data-aggregator

A semantic monitoring framework for aggregating data from heterogeneous sources.
Apache License 2.0
4 stars 0 forks source link

Mvn in Docker with multi-stage builds #127

Closed ghost closed 1 year ago

ghost commented 1 year ago

DESCRIPTION

The actual way of deploying a flink application is to use Maven locally to package the application into a .jar, that jar is uploaded to Github and used into a Dockerfile to be copied with the flink cluster. This method makes difficult to maintain changes into the applications because every modification will later need to delete the previous .jar file and upload a new one.

The solution is to copy the source code into the image and not the .jar file, later use the installed dependencies of Maven inside of the image to package the application. In order to reduce significantly the size of the builds, Docker multi-stage builds can be used so the final image only contains the generated .jar and not the Maven libraries and the source code.

A possibly useful example can be read in how to dockerize maven project.