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 9fc354a8fe8..2352ca9b58c 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,12 +27,12 @@ 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 "/home/git/gitlab/lib/gitlab/cluster/puma_worker_killer_initializer"
85+require_relative ENV['GITLAB_PATH'] + "lib/gitlab/cluster/lifecycle_events"
86+require_relative ENV['GITLAB_PATH'] + "lib/gitlab/cluster/puma_worker_killer_initializer"
87
88 on_restart do
89 # Signal application hooks that we're about to restart
90@@ -80,7 +76,7 @@ if defined?(nakayoshi_fork)
91 end
92
93 # Use json formatter
94-require_relative "/home/git/gitlab/lib/gitlab/puma_logging/json_formatter"
95+require_relative ENV['GITLAB_PATH'] + "lib/gitlab/puma_logging/json_formatter"
96
97 json_formatter = Gitlab::PumaLogging::JSONFormatter.new
98 log_formatter do |str|
99diff --git a/lib/api/api.rb b/lib/api/api.rb
100index a287ffbfcd8..1a5ca59183a 100644
101--- a/lib/api/api.rb
102+++ b/lib/api/api.rb
103@@ -4,7 +4,7 @@ module API
104 class API < ::API::Base
105 include APIGuard
106
107- LOG_FILENAME = Rails.root.join("log", "api_json.log")
108+ LOG_FILENAME = File.join(ENV["GITLAB_LOG_PATH"], "api_json.log")
109
110 NO_SLASH_URL_PART_REGEX = %r{[^/]+}.freeze
111 NAMESPACE_OR_PROJECT_REQUIREMENTS = { id: NO_SLASH_URL_PART_REGEX }.freeze
112diff --git a/lib/gitlab/authorized_keys.rb b/lib/gitlab/authorized_keys.rb
113index 50cd15b7a10..3ac89e5b8e9 100644
114--- a/lib/gitlab/authorized_keys.rb
115+++ b/lib/gitlab/authorized_keys.rb
116@@ -157,7 +157,7 @@ def command(id)
117 raise KeyError, "Invalid ID: #{id.inspect}"
118 end
119
120- "#{File.join(Gitlab.config.gitlab_shell.path, 'bin', 'gitlab-shell')} #{id}"
121+ "#{File.join('/run/current-system/sw/bin', 'gitlab-shell')} #{id}"
122 end
123
124 def strip(key)
125diff --git a/lib/gitlab/logger.rb b/lib/gitlab/logger.rb
126index 89a4e36a232..ae379ffb27a 100644
127--- a/lib/gitlab/logger.rb
128+++ b/lib/gitlab/logger.rb
129@@ -37,7 +37,7 @@ def self.build
130 end
131
132 def self.full_log_path
133- Rails.root.join("log", file_name)
134+ File.join(ENV["GITLAB_LOG_PATH"], file_name)
135 end
136
137 def self.cache_key
138diff --git a/lib/gitlab/uploads_transfer.rb b/lib/gitlab/uploads_transfer.rb
139index e0e7084e27e..19fab855b90 100644
140--- a/lib/gitlab/uploads_transfer.rb
141+++ b/lib/gitlab/uploads_transfer.rb
142@@ -3,7 +3,7 @@
143 module Gitlab
144 class UploadsTransfer < ProjectTransfer
145 def root_dir
146- FileUploader.root
147+ ENV['GITLAB_UPLOADS_PATH'] || FileUploader.root
148 end
149 end
150 end
151diff --git a/lib/system_check/app/log_writable_check.rb b/lib/system_check/app/log_writable_check.rb
152index 2c108f0c18d..3a16ff52d01 100644
153--- a/lib/system_check/app/log_writable_check.rb
154+++ b/lib/system_check/app/log_writable_check.rb
155@@ -23,7 +23,7 @@ def show_error
156 private
157
158 def log_path
159- Rails.root.join('log')
160+ ENV["GITLAB_LOG_PATH"]
161 end
162 end
163 end
164diff --git a/lib/system_check/app/uploads_directory_exists_check.rb b/lib/system_check/app/uploads_directory_exists_check.rb
165index 54dff63ab61..882da702f29 100644
166--- a/lib/system_check/app/uploads_directory_exists_check.rb
167+++ b/lib/system_check/app/uploads_directory_exists_check.rb
168@@ -6,12 +6,13 @@ class UploadsDirectoryExistsCheck < SystemCheck::BaseCheck
169 set_name 'Uploads directory exists?'
170
171 def check?
172- File.directory?(Rails.root.join('public/uploads'))
173+ File.directory?(ENV['GITLAB_UPLOADS_PATH'] || Rails.root.join('public/uploads'))
174 end
175
176 def show_error
177+ uploads_dir = ENV['GITLAB_UPLOADS_PATH'] || Rails.root.join('public/uploads')
178 try_fixing_it(
179- "sudo -u #{gitlab_user} mkdir #{Rails.root}/public/uploads"
180+ "sudo -u #{gitlab_user} mkdir #{uploads_dir}"
181 )
182 for_more_information(
183 see_installation_guide_section('GitLab')
184diff --git a/lib/system_check/app/uploads_path_permission_check.rb b/lib/system_check/app/uploads_path_permission_check.rb
185index 2e1cc687c43..ca69d63bcf6 100644
186--- a/lib/system_check/app/uploads_path_permission_check.rb
187+++ b/lib/system_check/app/uploads_path_permission_check.rb
188@@ -27,7 +27,7 @@ def show_error
189 private
190
191 def rails_uploads_path
192- Rails.root.join('public/uploads')
193+ ENV['GITLAB_UPLOADS_PATH'] || Rails.root.join('public/uploads')
194 end
195
196 def uploads_fullpath
197diff --git a/lib/system_check/app/uploads_path_tmp_permission_check.rb b/lib/system_check/app/uploads_path_tmp_permission_check.rb
198index 567c7540777..29906b1c132 100644
199--- a/lib/system_check/app/uploads_path_tmp_permission_check.rb
200+++ b/lib/system_check/app/uploads_path_tmp_permission_check.rb
201@@ -35,7 +35,7 @@ def upload_path_tmp
202 end
203
204 def uploads_fullpath
205- File.realpath(Rails.root.join('public/uploads'))
206+ File.realpath(ENV['GITLAB_UPLOADS_PATH'] || Rails.root.join('public/uploads'))
207 end
208 end
209 end
210diff --git a/scripts/decomposition/generate-loose-foreign-key b/scripts/decomposition/generate-loose-foreign-key
211index 35f84c64ce1..c2fecf3404c 100755
212--- a/scripts/decomposition/generate-loose-foreign-key
213+++ b/scripts/decomposition/generate-loose-foreign-key
214@@ -1,4 +1,4 @@
215-#!/usr/bin/env -S ENABLE_SPRING=0 bin/rails runner -e test
216+#!/usr/bin/env rails
217
218 # This is helper script to swap foreign key to loose foreign key
219 # using DB schema