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' -delete
Also 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 174MB
Example 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.3MB
Update:
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' -delete
We can reduce image size if remove all C/C++ headers from the
includedirectories. 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):
Also consider to clean up doc and html, localization files directories in the
/usr/local/lib/R/library.Results.
Example 1:
Example 2
Update:
Also
*.mo,*.pdffiles can be removed: