diff --git a/config/projects/gitlab.rb b/config/projects/gitlab.rb
index 2fee6c0e0d5fa90ed64b5c588967f2a9800c3abf_Y29uZmlnL3Byb2plY3RzL2dpdGxhYi5yYg==..81612bc34bfc10de5863974c7a010c2d252f7fec_Y29uZmlnL3Byb2plY3RzL2dpdGxhYi5yYg== 100644
--- a/config/projects/gitlab.rb
+++ b/config/projects/gitlab.rb
@@ -96,5 +96,8 @@
 dependency 'go-crond'
 dependency 'docker-distribution-pruner'
 
+dependency 'chef-acme'
+dependency 'mail_room'
+dependency 'grafana-dashboards'
 if Build::Check.include_ee?
   dependency 'consul'
@@ -99,5 +102,19 @@
 if Build::Check.include_ee?
   dependency 'consul'
+  dependency 'pgbouncer-exporter'
+end
+dependency 'alertmanager'
+dependency 'node-exporter'
+dependency 'redis-exporter'
+dependency 'postgres-exporter'
+dependency 'prometheus'
+dependency 'grafana'
+dependency 'gitlab-exporter'
+dependency 'mattermost'
+
+# Components that depend on the contents of this repository tends to dirty the
+# cache frequently than vendored components.
+if Build::Check.include_ee?
   dependency 'gitlab-ctl-ee'
   dependency 'gitlab-geo-psql'
   dependency 'gitlab-pg-ctl'
@@ -101,5 +118,4 @@
   dependency 'gitlab-ctl-ee'
   dependency 'gitlab-geo-psql'
   dependency 'gitlab-pg-ctl'
-  dependency 'pgbouncer-exporter'
 end
@@ -105,17 +121,5 @@
 end
-
-dependency 'mattermost'
-dependency 'prometheus'
-dependency 'alertmanager'
-dependency 'grafana'
-dependency 'grafana-dashboards'
-dependency 'mail_room'
-dependency 'node-exporter'
-dependency 'redis-exporter'
-dependency 'postgres-exporter'
-dependency 'gitlab-exporter'
-dependency 'gitlab-shell'
-dependency 'gitlab-pages'
+dependency 'gitlab-cookbooks'
 dependency 'gitlab-ctl'
 dependency 'gitlab-psql'
 dependency 'gitlab-redis-cli'
@@ -119,5 +123,4 @@
 dependency 'gitlab-ctl'
 dependency 'gitlab-psql'
 dependency 'gitlab-redis-cli'
-dependency 'gitlab-kas'
 dependency 'gitlab-healthcheck'
@@ -123,5 +126,3 @@
 dependency 'gitlab-healthcheck'
-dependency 'gitlab-cookbooks'
-dependency 'chef-acme'
 dependency 'gitlab-selinux'
 dependency 'gitlab-scripts'
@@ -126,3 +127,4 @@
 dependency 'gitlab-selinux'
 dependency 'gitlab-scripts'
+dependency 'package-scripts'
 dependency 'gitlab-config-template'
@@ -128,5 +130,13 @@
 dependency 'gitlab-config-template'
-dependency 'package-scripts'
+
+# Build GitLab components at the end because except for tag pipelines, we build
+# from `main`/`master`, and this can invalidate cache easily. Git is built from
+# gitaly sources, and hence falls under the same category.
+dependency 'gitlab-elasticsearch-indexer' if Build::Check.include_ee?
+
+dependency 'gitlab-kas'
+dependency 'gitlab-shell'
+dependency 'gitlab-pages'
 dependency 'git'
 
 # gitaly needs grpc to work correctly. These native extensions are built as part
diff --git a/config/software/gitlab-rails.rb b/config/software/gitlab-rails.rb
index 2fee6c0e0d5fa90ed64b5c588967f2a9800c3abf_Y29uZmlnL3NvZnR3YXJlL2dpdGxhYi1yYWlscy5yYg==..81612bc34bfc10de5863974c7a010c2d252f7fec_Y29uZmlnL3NvZnR3YXJlL2dpdGxhYi1yYWlscy5yYg== 100644
--- a/config/software/gitlab-rails.rb
+++ b/config/software/gitlab-rails.rb
@@ -55,7 +55,6 @@
 if EE
   dependency 'pgbouncer'
   dependency 'patroni'
-  dependency 'gitlab-elasticsearch-indexer'
 end
 
 # libatomic is a runtime_dependency of the grpc gem for armhf/aarch64 platforms