I have a dockerfile which has following stages/layers
COPY --from=build /usr/local /usr/local
COPY --from=build /home/platform /home/platform
COPY --from=build /usr/lib /usr/lib
here: build is the name of first stage and platform is just the code files.
Is it possible to inline all these copy statements in one so that layer count can be lowered ?
Already tried
COPY README.md package.json gulpfile.js __BUILD_NUMBER ./
This seems to be working only for copying in single folder.
I want Something like
RUN --from build cp -r /usr/local /usr/local/ && \
cp -r /home/platform /home/platform/ && \
cp -r /usr/lib /usr/lib/ \
Let me know if there is anything confusing. Thanks in Advance
If you really want to minimize the number of layers, you can copy your final image into a new, 'really final' image based on scratch.
Something like
You'll need to set up any ENTRYPOINT, CMD, ENV etc. in the
reallyfinalimage.Depending on your use-case it might be worth it or not. Personally, I don't think it's worth it if your only goal is to minimize the number of layers.