Closed artis3n closed 4 years ago
Thanks for the instructions! There is not a way to ignore paths, and previous stages in the multi stage build should not be included in the analysis.
In the specific case here the duplicate path is not due to the COPY
instruction, but instead the chown
command is causing the /app
directory contents to be copied up to the current layer.
If you modify:
COPY --from=compiler /app /app
# Set up non-root user
RUN groupadd -g 1000 modeler \
&& useradd -m -u 1000 -g modeler modeler \
&& chown -R modeler:modeler /app
To:
# Set up non-root user
RUN groupadd -g 1000 modeler \
&& useradd -m -u 1000 -g modeler modeler
COPY --chown=modeler:modeler --from=compiler /app /app
... you shouldn't see /app
as a duplicate path and get 15-ish MB back :) .
:O
TIL about --chown
. That's great, thanks.
When I build a container in a single image that compiles an app into
/app
,dive
rightfully considers/app
important and doesn't list that content as inefficient or wastedBytes.However, when I move this Dockerfile into a multi-stage build and
COPY --from=0 /app /app
,dive
considers the/app
directory as wasted bytes. Is there a way to explicitly tell dive to consider this directory important?Reproduce:
Single image:
Multi-stage: