Compare commits

...

4 Commits

Author SHA1 Message Date
Daniel Duvall 0134dc97bd Merge branch 'support-local-gems' into 'master'
Support loading of locally installed gems

See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7101

Merged-by: Daniel Duvall <dan@mutual.io>
Co-authored-by: Dan Duvall <dduvall@wikimedia.org>
2024-05-06 18:59:43 +00:00
Andrew Patterson 196b5a3326 Merge branch 'deps/19dfc8b-42de0a3' into 'master'
Update gitlab-org/container-registry from v3.93.0-gitlab to v4.0.0-gitlab

See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7580

Merged-by: Andrew Patterson <apatterson@gitlab.com>
Approved-by: Clemens Beck <cbeck@gitlab.com>
Approved-by: Andrew Patterson <apatterson@gitlab.com>
Co-authored-by: deps <bot@dependencies.io>
2024-05-06 17:32:03 +00:00
deps 242873ad43 Update gitlab-org/container-registry from v3.93.0-gitlab to v4.0.0-gitlab
Changelog: changed
2024-05-02 08:21:39 +00:00
Dan Duvall bc7be17370 Support loading of locally installed gems
Allow administrators to load additional gems during gitlab-rails
initialization via `gitlab.rb` configuration.

This is a general approach that may satisfy many different use cases.
Some examples are:

 1. Enabling additional OmniAuth strategies.
    Ref https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/1420
 2. Integrations that are specific to on-premise installations and not
    appropriate for contribution to upstream gitlab-ce.

Note that gems can only be sourced from local directories and must be
installed prior to `gitlab-ctl reconfigure`. This reduces the complexity
of the implementation in comparison to one that would install gems from
remote sources and ensures the Bundler config can maintain its frozen
state between reconfigurations. Administrators can choose which method
of installation makes sense for their environment, e.g. Bundler, distro
packages, or some configuration management.

If local gems are defined, a `Gemfile.local` is created that wraps the
original `Gemfile` and defines a `path` source section for each set of
gems in `gitlab_rails['gems']`. Using `path` constrains gems to the
local path source.

Example configuration:

```
gitlab_rails['gems'] = {
  '/a/local/dir/of/vendored/gems' => ['some_gem', 'another_gem'],
}
```

Resulting `Gemfile.local`:

```
eval_gemfile("Gemfile")

path "/a/local/dir/of/vendored/gems" do
  gem "some_gem"
  gem "another_gem"
end
```
2023-08-22 20:51:59 -07:00
4 changed files with 64 additions and 4 deletions

View File

@ -19,7 +19,7 @@
require "#{Omnibus::Config.project_root}/lib/gitlab/version"
name 'registry'
version = Gitlab::Version.new('registry', 'v3.93.0-gitlab')
version = Gitlab::Version.new('registry', 'v4.0.0-gitlab')
default_version version.print(false)
display_version version.print(false).delete_suffix('-gitlab')

View File

@ -609,6 +609,15 @@ external_url 'GENERATED_EXTERNAL_URL'
# gitlab_rails['duo_auth_secret_key'] = 'duo_auth_secret_key'
# gitlab_rails['duo_auth_hostname'] = 'duo_auth.example.com'
### Additional gems to load during initialization
###! Note, all gems must be present in the given path already, for example
### using `bundle install` or some other means. Nothing will be installed
### from external sources by gitlab-ctl.
###! Docs (TODO): https://docs.gitlab.com/omnibus/settings/gems.html
# gitlab_rails['gems'] = {
# '/opt/local/gitlab/gems' => ['some_gem_name'],
# }
### Backup Settings
###! Docs: https://docs.gitlab.com/omnibus/settings/backups.html

View File

@ -31,6 +31,8 @@ gitlab_rails_working_dir = File.join(gitlab_rails_dir, "working")
gitlab_rails_tmp_dir = File.join(gitlab_rails_dir, "tmp")
gitlab_rails_public_uploads_dir = node['gitlab']['gitlab_rails']['uploads_directory']
gitlab_rails_uploads_storage_path = node['gitlab']['gitlab_rails']['uploads_storage_path']
gitlab_rails_gemfile = GitlabRailsEnvHelper.bundle_gemfile(gitlab_rails_source_dir)
gitlab_rails_gemfile_local = File.join(gitlab_rails_source_dir, "Gemfile.local")
gitlab_ci_dir = node['gitlab']['gitlab_ci']['dir']
gitlab_ci_builds_dir = node['gitlab']['gitlab_ci']['builds_directory']
gitlab_rails_shared_tmp_dir = File.join(node['gitlab']['gitlab_rails']['shared_path'], 'tmp')
@ -487,11 +489,47 @@ end
gitlab_relative_url = node['gitlab']['gitlab_rails']['gitlab_relative_url']
rails_env['RAILS_RELATIVE_URL_ROOT'] = gitlab_relative_url if gitlab_relative_url
rails_env['BUNDLE_GEMFILE'] = GitlabRailsEnvHelper.bundle_gemfile(gitlab_rails_source_dir)
rails_env['PUMA_WORKER_MAX_MEMORY'] = node['gitlab']['puma']['per_worker_max_memory_mb']
if node['gitlab']['gitlab_rails'].include?('gems')
# Additional gems are configured. Create a Gemfile.local that wraps the
# original Gemfile and includes local gems
template "Creating Gemfile.local for local gems" do
path gitlab_rails_gemfile_local
source "gemfile.local.erb"
variables node['gitlab']['gitlab_rails'].to_hash.merge(gemfile: gitlab_rails_gemfile)
notifies :run, "bash[Update Gemfile.local.lock]", :immediately
end
bash "Update Gemfile.local.lock" do
cwd File.dirname(gitlab_rails_gemfile_local)
code <<~CODE
cp #{gitlab_rails_gemfile.inspect}.lock Gemfile.local.lock
/opt/gitlab/embedded/bin/bundle lock --local
CODE
environment(
{
BUNDLE_IGNORE_CONFIG: "1", # this is necessary to bypass the frozen state
BUNDLE_GEMFILE: gitlab_rails_gemfile_local,
}
)
action :nothing
dependent_services.each { |svc| notifies :restart, svc }
end
rails_env['BUNDLE_GEMFILE'] = gitlab_rails_gemfile_local
else
file gitlab_rails_gemfile_local do
action :delete
end
file "#{gitlab_rails_gemfile_local}.lock" do
action :delete
end
rails_env['BUNDLE_GEMFILE'] = gitlab_rails_gemfile
end
env_dir File.join(gitlab_rails_static_etc_dir, 'env') do
variables(
rails_env.merge(node['gitlab']['gitlab_rails']['env'])

View File

@ -0,0 +1,13 @@
# This file is managed by gitlab-ctl. Manual changes will be
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
# and run `sudo gitlab-ctl reconfigure`.
eval_gemfile(<%= @gemfile.inspect %>)
<% @gems.each do |path, gems| %>
path <%= path.inspect %> do
<%- gems.each do |gem| %>
gem <%= gem.inspect %>
<%- end %>
end
<% end %>