2 ms·
EDIT: Provide example below If you are doing multi stage builds it only matters to combined as many statements as possible in the last layer. I agree that for
by verst 6y ago
EDIT: Provide example below
If you are doing multi stage builds it only matters to combined as many statements as possible in the last layer.
I agree that for clarity it is nice not to optimize layers in the build stage - those will be thrown away anyway.
I vastly prefer multi stage builds over having to chain install and cleanup statements
Example: I usually want to use the python:3-slim image, but this doesn't have the tools to compile certain python libraries with C extensions. Generally I will use the python:3 image for my build stage to do my "pip install -r requirements.txt" and then copy the libraries over to my final stage based on the python:3-slim image
Of course I could install and uninstall GCC and other tools in a single stage.. but that actually takes longer to do and is messier in my opinion.
- jackthetab 6y ago> Example: I usually want to use the python:3-slim image, but this doesn't have the tools to compile certain python libraries with C extensions. Generally I will use the python:3 image for my build stage to do my "pip install -r requirements.txt" and then copy the libraries over to my final stage based on the python:3-slim image Example on how to do that, please.