Speedup Docker Gentoo Image Build

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 MAKEOPTS in /etc/portage/make.conf

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

Happy compiling.

Hello, World!

Yeah, works. Back in 1974 the book The C Programming Language… err… I think you know what I mean. But we’re not in C neither in B. Currently this blog is not a real C application but under the hood it’s C, C++ and JavaScript. Yes, it’s JavaScript. An io.js (originally based on Node.js) powered blog engine called Hexo. Running within a Docker container. And Docker in running within a virtual machine powered by Gentoo. This is the current setup. Within the next weeks I’ll post some great news about Linux, Open Source, various (multimedia) software and - of course - my own projects here so be sure you subscribed to the RSS-Feed or follow me on Google+.