Skip to content

Only copy the workhorse folder from gitlab-rails-ee

David Dieulivol requested to merge ddieulivol-speed_up_workhorse_a_bit into master

Context

In review-apps pipelines, gitlab-workhorse-ee is the longest phase 6 job. Speeding it up will speed up the critical path for deploying review-apps.

When building the gitlab-workhorse image, we are currently copying the entire GitLab rails application with COPY --from=rails /srv/gitlab/ ${BUILD_DIR}/, which takes around 16 seconds (see timings).

What does this MR do?

Speed up the gitlab-workhorse-ee job by only copying the gitlab/workhorse folder for building gitlab-workhorse.

This change will save around 16 seconds 🎉 🚀

Does this produce the same image?

Using the following container image tags:

Command

$ container-diff diff \
  registry.gitlab.com/gitlab-org/build/cng/gitlab-workhorse-ee:023124cb37fa9e3c83ea1c00f82b71f7b197a9f5 \
  registry.gitlab.com/gitlab-org/build/cng/gitlab-workhorse-ee:d069c12dac564330f5eb938b198ce6dce71b0112 \
  -t file | grep -v /srv/gitlab/bootsnap | grep -v /srv/gitlab/public/assets

Output

-----File-----

These entries have been added to registry.gitlab.com/gitlab-org/build/cng/gitlab-workhorse-ee:023124cb37fa9e3c83ea1c00f82b71f7b197a9f5:
FILE                                                                                                                                                                            SIZE

These entries have been deleted from registry.gitlab.com/gitlab-org/build/cng/gitlab-workhorse-ee:023124cb37fa9e3c83ea1c00f82b71f7b197a9f5:
FILE                                                                                                                                                                            SIZE

These entries have been changed between registry.gitlab.com/gitlab-org/build/cng/gitlab-workhorse-ee:023124cb37fa9e3c83ea1c00f82b71f7b197a9f5 and registry.gitlab.com/gitlab-org/build/cng/gitlab-workhorse-ee:d069c12dac564330f5eb938b198ce6dce71b0112:
FILE                                                                                                                                                                                                               SIZE1         SIZE2
/usr/local/bin/gitlab-workhorse                                                                                                                                                                                    42.6M         42.6M
/usr/local/bin/gitlab-zip-metadata                                                                                                                                                                                 8.2M          8.2M
/usr/local/bin/gitlab-zip-cat                                                                                                                                                                                      8.2M          8.2M
/usr/local/bin/gitlab-resize-image                                                                                                                                                                                 2.6M          2.6M
/srv/gitlab/doc/development/service_ping/metrics_instrumentation.md                                                                                                                                                17.2K         17.2K
/var/log/dpkg.log                                                                                                                                                                                                  12.3K         12.3K
/srv/gitlab/doc/api/import.md                                                                                                                                                                                      8.7K          8.6K
/var/log/apt/term.log                                                                                                                                                                                              7.4K          7.4K
/var/cache/ldconfig/aux-cache                                                                                                                                                                                      6.3K          6.3K
/var/log/apt/history.log                                                                                                                                                                                           1.3K          1.3K
/var/log/alternatives.log                                                                                                                                                                                          278B          278B
/usr/local/lib/x86_64-linux-gnu/perl/5.32.1/perllocal.pod                                                                                                                                                          245B          245B

I also compared the versions as a basic smoke test:

$ docker run registry.gitlab.com/gitlab-org/build/cng/gitlab-workhorse-ee:d069c12dac564330f5eb938b198ce6dce71b0112 /usr/local/bin/gitlab-workhorse --version
Begin parsing .tpl templates from /etc
gitlab-workhorse (v15.10.0-pre)-(20230307.051307)

$ docker run registry.gitlab.com/gitlab-org/build/cng/gitlab-workhorse-ee:023124cb37fa9e3c83ea1c00f82b71f7b197a9f5 /usr/local/bin/gitlab-workhorse --version
Begin parsing .tpl templates from /etc
gitlab-workhorse (v15.10.0-pre)-(20230307.091144)

Checklist

See Definition of done.

For anything in this list which will not be completed, please provide a reason in the MR discussion

Required

  • Merge Request Title, and Description are up to date, accurate, and descriptive
  • MR targeting the appropriate branch
  • MR has a green pipeline on GitLab.com

Expected (please provide an explanation if not completing)

  • Test plan indicating conditions for success has been posted and passes
  • Documentation created/updated
  • Integration tests added to GitLab QA
  • The impact any change in container size has should be evaluated
Edited by Jason Plum

Merge request reports