aabarmin / epam-microservices-training-2022

Apache License 2.0
14 stars 15 forks source link

Containerize monolithic layered app #46

Closed youngInnovator closed 11 months ago

aabarmin commented 11 months ago

This looks like a good option, I am slightly worried that this approach will download dependencies every time the container is created from the image. What do you think, would it be better if monolithic apps are built using the same approach as all other microservices - using docker/build.sh script?

The script is already available here - https://github.com/aabarmin/epam-microservices-training-2022/blob/main/buildscripts/build.sh

To add support of a new application, it is necessary to add a line like:

docker build \
    --build-arg module_path=monolithic/monolithic-layered \
    -t monolithic/monolithic-layered:latest \
    -f ./Dockerfile ..

This script will automatically build a jar artifact from the Spring Boot application and next generate a Docker image.

youngInnovator commented 11 months ago

I am just thinking it will require building tools to be installed locally to prepare .jar and will fail in case of the jar is not available. But I agree with you and also feel it will improve the overall build process and image size as well. I will update the MR

aabarmin commented 11 months ago

Thank you @youngInnovator for considering my comment. Let me think if I can introduce a multi-step build that will allow to build a jar file in a container and next create an image. Something like this - https://www.alibabacloud.com/help/en/acr/use-cases/build-an-image-for-a-java-application-by-using-a-dockerfile-with-multi-stage-builds