Skip to content

Draft: Improve caching for gitlab-rails image build

What does this MR do?

Refactor gitlab-rails Dockerfile to support better layer caching. This mr moves rails code fetching outside of docker build process which allows:

  • caching gem install step separately
  • caching node dependency step separately
  • installing gems and node dependencies in parallel

Additional minor improvements:

  • allows to override CACHE_BUSTER variable when triggering build upstream
  • allows to override default CI_PIPELINE_CREATED_AT suffix for container version computation
  • fixes warnings produced by buildkit due to non matching case usage for as keyword
  • replace hardcoded duplicate values with respective ARG values, like git user or /var/opt/gitlab folder

Related issues

Part of: gitlab-org/quality/quality-engineering/team-tasks#2822 (closed)
Closes: gitlab-org/quality/quality-engineering/team-tasks#2825 (closed)

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
  • When ready for review, MR is labeled "~workflow::ready for review" per the Distribution MR workflow

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
  • New dependencies are managed with dependencies.io

Image size

Final rails image is the same as before the change of this merge request.

registry.gitlab.com/gitlab-org/build/cng/gitlab-rails-ee                              andrey-cacheable-gitlab-rails                     e35c5ce5f298   49 minutes ago   3.18GB
registry.gitlab.com/gitlab-org/build/cng/gitlab-rails-ee                              master                                            7145f0a58ce2   10 hours ago     3.18GB
Edited by Andrejs Cunskis

Merge request reports