1diff --git a/config/environments/production.rb b/config/environments/production.rb
2index e1a7db8d860..5823f170410 100644
3--- a/config/environments/production.rb
4+++ b/config/environments/production.rb
5@@ -71,10 +71,10 @@
6
7 config.action_mailer.delivery_method = :sendmail
8 # Defaults to:
9- # # config.action_mailer.sendmail_settings = {
10- # # location: '/usr/sbin/sendmail',
11- # # arguments: '-i -t'
12- # # }
13+ config.action_mailer.sendmail_settings = {
14+ location: '/run/wrappers/bin/sendmail',
15+ arguments: '-i -t'
16+ }
17 config.action_mailer.perform_deliveries = true
18 config.action_mailer.raise_delivery_errors = true
19
20diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
21index da1a15302da..c846db93e5c 100644
22--- a/config/gitlab.yml.example
23+++ b/config/gitlab.yml.example
24@@ -1191,7 +1191,7 @@ production: &base
25 # CAUTION!
26 # Use the default values unless you really know what you are doing
27 git:
28- bin_path: /usr/bin/git
29+ bin_path: git
30
31 ## Webpack settings
32 # If enabled, this will tell rails to serve frontend assets from the webpack-dev-server running
33diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
34index d096174fca3a..02d0f689c523 100644
35--- a/config/initializers/1_settings.rb
36+++ b/config/initializers/1_settings.rb
37@@ -206,7 +206,7 @@
38 Settings.gitlab['user_home'] ||= begin
39 Etc.getpwnam(Settings.gitlab['user']).dir
40 rescue ArgumentError # no user configured
41- '/home/' + Settings.gitlab['user']
42+ '/homeless-shelter'
43 end
44 Settings.gitlab['time_zone'] ||= nil
45 Settings.gitlab['signup_enabled'] ||= true if Settings.gitlab['signup_enabled'].nil?
46@@ -959,7 +959,7 @@
47 # Git
48 #
49 Settings['git'] ||= {}
50-Settings.git['bin_path'] ||= '/usr/bin/git'
51+Settings.git['bin_path'] ||= 'git'
52
53 # Important: keep the satellites.path setting until GitLab 9.0 at
54 # least. This setting is fed to 'rm -rf' in
55diff --git a/config/puma.rb.example b/config/puma.rb.example
56index 07a6f6a25015..14a718a43202 100644
57--- a/config/puma.rb.example
58+++ b/config/puma.rb.example
59@@ -5,12 +5,8 @@
60 # The default is "config.ru".
61 #
62 rackup 'config.ru'
63-pidfile '/home/git/gitlab/tmp/pids/puma.pid'
64-state_path '/home/git/gitlab/tmp/pids/puma.state'
65-
66-stdout_redirect '/home/git/gitlab/log/puma.stdout.log',
67- '/home/git/gitlab/log/puma.stderr.log',
68- true
69+pidfile ENV['PUMA_PATH'] + '/tmp/pids/puma.pid'
70+state_path ENV['PUMA_PATH'] + '/tmp/pids/puma.state'
71
72 # Configure "min" to be the minimum number of threads to use to answer
73 # requests and "max" the maximum.
74@@ -31,11 +27,11 @@ queue_requests false
75
76 # Bind the server to "url". "tcp://", "unix://" and "ssl://" are the only
77 # accepted protocols.
78-bind 'unix:///home/git/gitlab/tmp/sockets/gitlab.socket'
79+bind "unix://#{ENV['PUMA_PATH']}/tmp/sockets/gitlab.socket"
80
81 workers 3
82
83-require_relative "/home/git/gitlab/lib/gitlab/cluster/lifecycle_events"
84+require_relative ENV['GITLAB_PATH'] + "lib/gitlab/cluster/lifecycle_events"
85
86 on_restart do
87 # Signal application hooks that we're about to restart
88@@ -74,7 +70,7 @@ worker_timeout 60
89 wait_for_less_busy_worker ENV.fetch('PUMA_WAIT_FOR_LESS_BUSY_WORKER', 0.001).to_f
90
91 # Use json formatter
92-require_relative "/home/git/gitlab/lib/gitlab/puma_logging/json_formatter"
93+require_relative ENV['GITLAB_PATH'] + "lib/gitlab/puma_logging/json_formatter"
94
95 json_formatter = Gitlab::PumaLogging::JSONFormatter.new
96 log_formatter do |str|
97diff --git a/lib/api/api.rb b/lib/api/api.rb
98index a287ffbfcd8..1a5ca59183a 100644
99--- a/lib/api/api.rb
100+++ b/lib/api/api.rb
101@@ -4,7 +4,7 @@ module API
102 class API < ::API::Base
103 include APIGuard
104
105- LOG_FILENAME = Rails.root.join("log", "api_json.log")
106+ LOG_FILENAME = File.join(ENV["GITLAB_LOG_PATH"], "api_json.log")
107
108 NO_SLASH_URL_PART_REGEX = %r{[^/]+}.freeze
109 NAMESPACE_OR_PROJECT_REQUIREMENTS = { id: NO_SLASH_URL_PART_REGEX }.freeze
110diff --git a/lib/gitlab/authorized_keys.rb b/lib/gitlab/authorized_keys.rb
111index 50cd15b7a10..3ac89e5b8e9 100644
112--- a/lib/gitlab/authorized_keys.rb
113+++ b/lib/gitlab/authorized_keys.rb
114@@ -157,7 +157,7 @@ def command(id)
115 raise KeyError, "Invalid ID: #{id.inspect}"
116 end
117
118- "#{File.join(Gitlab.config.gitlab_shell.path, 'bin', 'gitlab-shell')} #{id}"
119+ "#{File.join('/run/current-system/sw/bin', 'gitlab-shell')} #{id}"
120 end
121
122 def strip(key)
123diff --git a/lib/gitlab/logger.rb b/lib/gitlab/logger.rb
124index 89a4e36a232..ae379ffb27a 100644
125--- a/lib/gitlab/logger.rb
126+++ b/lib/gitlab/logger.rb
127@@ -37,7 +37,7 @@ def self.build
128 end
129
130 def self.full_log_path
131- Rails.root.join("log", file_name)
132+ File.join(ENV["GITLAB_LOG_PATH"], file_name)
133 end
134
135 def self.cache_key
136diff --git a/lib/gitlab/uploads_transfer.rb b/lib/gitlab/uploads_transfer.rb
137index e0e7084e27e..19fab855b90 100644
138--- a/lib/gitlab/uploads_transfer.rb
139+++ b/lib/gitlab/uploads_transfer.rb
140@@ -3,7 +3,7 @@
141 module Gitlab
142 class UploadsTransfer < ProjectTransfer
143 def root_dir
144- FileUploader.root
145+ ENV['GITLAB_UPLOADS_PATH'] || FileUploader.root
146 end
147 end
148 end
149diff --git a/lib/system_check/app/log_writable_check.rb b/lib/system_check/app/log_writable_check.rb
150index 2c108f0c18d..3a16ff52d01 100644
151--- a/lib/system_check/app/log_writable_check.rb
152+++ b/lib/system_check/app/log_writable_check.rb
153@@ -23,7 +23,7 @@ def show_error
154 private
155
156 def log_path
157- Rails.root.join('log')
158+ ENV["GITLAB_LOG_PATH"]
159 end
160 end
161 end
162diff --git a/lib/system_check/app/uploads_directory_exists_check.rb b/lib/system_check/app/uploads_directory_exists_check.rb
163index 54dff63ab61..882da702f29 100644
164--- a/lib/system_check/app/uploads_directory_exists_check.rb
165+++ b/lib/system_check/app/uploads_directory_exists_check.rb
166@@ -6,12 +6,13 @@ class UploadsDirectoryExistsCheck < SystemCheck::BaseCheck
167 set_name 'Uploads directory exists?'
168
169 def check?
170- File.directory?(Rails.root.join('public/uploads'))
171+ File.directory?(ENV['GITLAB_UPLOADS_PATH'] || Rails.root.join('public/uploads'))
172 end
173
174 def show_error
175+ uploads_dir = ENV['GITLAB_UPLOADS_PATH'] || Rails.root.join('public/uploads')
176 try_fixing_it(
177- "sudo -u #{gitlab_user} mkdir #{Rails.root}/public/uploads"
178+ "sudo -u #{gitlab_user} mkdir #{uploads_dir}"
179 )
180 for_more_information(
181 see_installation_guide_section('GitLab')
182diff --git a/lib/system_check/app/uploads_path_permission_check.rb b/lib/system_check/app/uploads_path_permission_check.rb
183index 2e1cc687c43..ca69d63bcf6 100644
184--- a/lib/system_check/app/uploads_path_permission_check.rb
185+++ b/lib/system_check/app/uploads_path_permission_check.rb
186@@ -27,7 +27,7 @@ def show_error
187 private
188
189 def rails_uploads_path
190- Rails.root.join('public/uploads')
191+ ENV['GITLAB_UPLOADS_PATH'] || Rails.root.join('public/uploads')
192 end
193
194 def uploads_fullpath
195diff --git a/lib/system_check/app/uploads_path_tmp_permission_check.rb b/lib/system_check/app/uploads_path_tmp_permission_check.rb
196index 567c7540777..29906b1c132 100644
197--- a/lib/system_check/app/uploads_path_tmp_permission_check.rb
198+++ b/lib/system_check/app/uploads_path_tmp_permission_check.rb
199@@ -35,7 +35,7 @@ def upload_path_tmp
200 end
201
202 def uploads_fullpath
203- File.realpath(Rails.root.join('public/uploads'))
204+ File.realpath(ENV['GITLAB_UPLOADS_PATH'] || Rails.root.join('public/uploads'))
205 end
206 end
207 end
208diff --git a/scripts/decomposition/generate-loose-foreign-key b/scripts/decomposition/generate-loose-foreign-key
209index 35f84c64ce1..c2fecf3404c 100755
210--- a/scripts/decomposition/generate-loose-foreign-key
211+++ b/scripts/decomposition/generate-loose-foreign-key
212@@ -1,4 +1,4 @@
213-#!/usr/bin/env -S ENABLE_SPRING=0 bin/rails runner -e test
214+#!/usr/bin/env rails
215
216 # This is helper script to swap foreign key to loose foreign key
217 # using DB schema