Upgrading development system; want to speed up docker build times

I’m a software engineer and a newer project has required me to build Docker images for regular releases on my system. The builds take quite some time to complete, and I’m wondering what upgrades I could make to my Desktop to speed this process up. (Compiling Rust application on top of an Alpine base system takes a bit of time for every build, and some times I’ve found myself having to rebuild images and fix images multiple times with significant waiting in between before I can test the new image).

I currently run Ubuntu 20.04 with a Ryzen 2700x and 32 GB of RAM, and have an M.2 hard drive.

Using the GNOME system monitor tool during my build, it appears that the CPU is being hit hardest (although I’m not entirely certain it’s not the result of wait time with slow disk I/O).

If I want to go about speeding up the image building times, should I try upgrading my CPU first? Is there a better tool(s) for profiling my system and finding the bottleneck?

1 Like

I think the first place to start profiling this is to use iostat. That should give you information about CPU and disk utilization, and the amount of time the CPU spends waiting on I/O.

2 Likes

I think this goes without saying but if there’s a way to layer your app you can make it so you don’t have to rebuild everything for small changes. I.e. lets say you have a backend container and the frontend is built FROM the backend, then front end changes won’t touch the backend stuff. But if you rebuild the backend I think you’re right back where you started

2 Likes

As @reavessm said, making use of the Docker cache will help a lot. I build a lot of Drupal images, so I’ve ended up splitting up the COPY commands so that the ones that change the most are at the bottom of the Dockerfile. That way I don’t waste time copying every single file, every single time.

Though, I’m not sure how that’d work with a Rust app.

As for hardware, my understanding is that most compiling is a CPU operation. So upgrading your CPU would improve things.

You might see an improvement switching to an nvme m.2 drive from a sata m.2 drive. But unless your app is many gigabytes in size, I kinda doubt you’d see much.

I honestly have no idea how RAM effects compiling programs. Or building Dockerfiles. But 32gb should be enough for most cases.

Anyway, that’s my two cents. Hope it at least points you in the right direction. :slight_smile:

1 Like

How long does it actually take to build? how much slower is it to compile on docker vs natively?

This topic was automatically closed 273 days after the last reply. New replies are no longer allowed.