-
Notifications
You must be signed in to change notification settings - Fork 36
Open
Labels
enhancementNew feature or requestNew feature or request
Description
We can reduce image size if remove all C/C++ headers from the include directories. For example, BH size is 126 Mb.
Note, only the final image can be optimized this way because headers no needs anymore.
My suggestion is to add the following command to the end of the examples (and FAQ):
rm -rf ~/.cache/* && \
rm -rf /var/cache/apk/* && \
find /usr/local/lib/R/library/ -type f -path '*/include/*' -name '*.h' -delete && \
find /usr/local/lib/R/library/ -type f -path '*/include/*' -name '*.hpp' -deleteAlso consider to clean up doc and html, localization files directories in the /usr/local/lib/R/library.
Results.
Example 1:
FROM rhub/r-minimal:4.1
RUN installr -d RcppUUID❯ docker build --no-cache -t test1 .
❯ docker image ls | grep test1
test1 latest 2de64ed9d50c 29 seconds ago 174MBExample 2
FROM rhub/r-minimal:4.1
RUN installr -d RcppUUID && \
find /usr/local/lib/R/library/ -type f -path '*/include/*' -name '*.h' -delete && \
find /usr/local/lib/R/library/ -type f -path '*/include/*' -name '*.hpp' -delete❯ docker build --no-cache -t test2 .
❯ docker image ls | grep test2
test2 latest 100b444eb7ec 3 seconds ago 44.3MBUpdate:
Also *.mo, *.pdf files can be removed:
find /usr/local/lib/R/library/ -type f -path '*/po/*' -name '*.mo' -delete
find /usr/local/lib/R/library/ -type f -path '*/doc/*' -name '*.pdf' -deleteMetadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request