Open nyurik opened 4 years ago
@nyurik:
in theory it is a good idea, but when I checked the best practice in the upstream repo ..
I realized that : the "multi-stage" builds is "heavily discouraged in official-images"
see https://github.com/docker-library/postgres/issues/655#issuecomment-566815226 ( search "stage" )
and see https://github.com/docker-library/faq/#multi-stage-builds
@ImreSamu thanks, I wasn't aware of the caching issue. I guess this is more of the build infrastructure shortcoming that should be solved on the server-side -- because otherwise you sacrifice bandwidth for the gain in build-time, but I do understand the concern.
That said, I think my proposal fits the 2nd case described in guidelines (if I understood it correctly):
two-stage build where the necessary artifact does not exist and must be built from source and/or the build process is going to be similarly highly deterministic (thus mitigating the cache concern somewhat)
I try to write multistage build on master branch.
The current 12-master/Dockerfile uses a single stage build, and tries to clean up at the end. I think it can be made significantly smaller by using a 2-stage build:
This should (in theory) make the resulting image smaller. The biggest issue is knowing how to copy results -- I suspect it is usually the package maintainers who track those dependencies.
cc: @smellman