When you’re using my Gentoo Docker Base Image or maybe other Gentoo based base images it’s always recommended to use a separate dedicated server to build your custom Docker images because it needs some time and
much of your available resources some memory to compile the packages. To speedup the build process it’s better to use all the CPU-power of this build machine. To do this, add a line to your Dockerfile which will add the number of CPUs of the current machine to your
FROM rndevfx/gentoo-stage3-amd64-nomultilib RUN echo "MAKEOPTS=\"-j$(cat /proc/cpuinfo | grep processor | wc -l)\"" >> /etc/portage/make.conf RUN emerge-webrsync RUN emerge ...
That’s it. If you want you can use the
nproc command as well. It’s part of GNU Coreutils and so it’s available within a stage3 archive. It looks a little bit easier if you want to set
CPUs + 1.
RUN echo "MAKEOPTS=\"-j$(expr $(nproc) + 1)\"" >> /etc/portage/make.conf