Skip to content

Switch to ruby slim images for critical path of rspec-ee unit pg* jobs

David Dieulivol requested to merge 385049-switch_ruby_images_to_alpine into master

Context

Looking at #385049 (closed), I've noticed that downloading the ruby:2.7 image takes around 17 seconds in some jobs on the critical path of the rspec-ee unit pg* jobs (namely retrieve-tests-metadata and detect-tests):

What does this MR do?

Switch the ruby:2.7 image to its slim counterpart, which is smaller, and therefore will download faster from the dependency proxy.

Difference in size between container images

$ docker images
REPOSITORY TAG              IMAGE ID        CREATED               PLATFORM          SIZE         BLOB SIZE
ruby       2.7              e337a1b74b67    3 hours ago           linux/arm64/v8    845.4 MiB    313.3 MiB
ruby       2.7-alpine3.16   b9b58c6bc64e    54 minutes ago        linux/arm64/v8    52.3 MiB     19.7 MiB
ruby       2.7-slim         1e52473bc559    About a minute ago    linux/arm64/v8    151.8 MiB    51.2 MiB

Why not alpine?

Alpine doesn't have bash, and the scripts/rspec_helpers.sh script uses some bashisms (e.g. <<<, arrays, ...). GitLab runner won't use bash, even if we install it, because it chooses the shell to use when first downloading the container image (source: gitlab-runner#1758 (comment 16419417)).

I could have rewritten the scripts/rspec_helpers.sh to be POSIX-compliant, but it felt like too much work for now for the improvement it would bring compared to using slim images (not to mention we don't have tests for those scripts, which makes refactorings trickier).

Improvements in the job

We saved 10 seconds per job 🚀 (they run in parallel, so the time saved on the critical path is single, not double).

Next up

This is a fairly easy change, and with a bit of testing, we could make to most CI jobs using ruby.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #385049 (closed)

Edited by David Dieulivol

Merge request reports