Skip to content
Snippets Groups Projects
Commit 6cb44a59 authored by Mike Greiling's avatar Mike Greiling
Browse files

remove assets:precompile step from reconfigure process and update rake task

parent 8dc221d1
No related branches found
No related tags found
1 merge request!1264Remove NodeJS as a production dependency
Loading
Loading
@@ -201,7 +201,7 @@ See [doc/common_installation_problems/README.md](doc/common_installation_problem
 
See [doc/common_installation_problems/README.md](doc/common_installation_problems/README.md#i-am-unable-to-install-omnibus-gitlab-without-root-access).
 
##### gitlab-rake assets:precompile fails with 'Permission denied'
##### gitlab-rake assets:precompile or gitlab:assets:compile fails with 'Permission denied'
 
See [doc/common_installation_problems/README.md](doc/common_installation_problems/README.md#gitlab-rake-assetsprecompile-fails-with-permission-denied).
 
Loading
Loading
Loading
Loading
@@ -82,21 +82,21 @@ build do
# Not using the patch DSL as we need the path to the gems directory
command "cat #{patch_file_path} | patch -p1 \"$(#{gemdir_cmd})/gems/gitlab-markup-1.5.1/lib/github/markups.rb\""
 
# In order to precompile the assets, we need to get to a state where rake can
# In order to compile the assets, we need to get to a state where rake can
# load the Rails environment.
copy 'config/gitlab.yml.example', 'config/gitlab.yml'
copy 'config/database.yml.postgresql', 'config/database.yml'
copy 'config/secrets.yml.example', 'config/secrets.yml'
 
assets_precompile_env = {
assets_compile_env = {
"RAILS_ENV" => "production",
"PATH" => "#{install_dir}/embedded/bin:#{ENV['PATH']}",
"USE_DB" => "false",
"SKIP_STORAGE_VALIDATION" => "true"
}
bundle "exec rake assets:precompile", :env => assets_precompile_env
bundle "exec rake gitlab:assets:compile", :env => assets_compile_env
 
# Tear down now that the assets:precompile is done.
# Tear down now that gitlab:assets:compile is done.
delete 'config/gitlab.yml'
delete 'config/database.yml'
delete 'config/secrets.yml'
Loading
Loading
Loading
Loading
@@ -75,7 +75,7 @@ Omnibus is a way to package different services and tools required to run GitLab,
- [Reconfigure fails to create the git user](common_installation_problems/README.md#reconfigure-fails-to-create-the-git-user).
- [Failed to modify kernel parameters with sysctl](common_installation_problems/README.md#failed-to-modify-kernel-parameters-with-sysctl).
- [I am unable to install omnibus-gitlab without root access](common_installation_problems/README.md#i-am-unable-to-install-omnibus-gitlab-without-root-access).
- [gitlab-rake assets:precompile fails with 'Permission denied'](common_installation_problems/README.md#gitlab-rake-assetsprecompile-fails-with-permission-denied).
- [gitlab-rake gitlab:assets:compile fails with 'Permission denied'](common_installation_problems/README.md#gitlab-rake-gitlabassetscompile-fails-with-permission-denied).
- ['Short read or OOM loading DB' error](common_installation_problems/README.md#short-read-or-oom-loading-db-error).
- ['pg_dump: aborting because of server version mismatch'](settings/database.md#using-a-non-packaged-postgresql-database-management-server)
- ['Errno::ENOMEM: Cannot allocate memory' during backup or upgrade](common_installation_problems/README.md#errnoenomem-cannot-allocate-memory-during-backup-or-upgrade)
Loading
Loading
Loading
Loading
@@ -147,8 +147,8 @@ shell and the `passwd` command for non-superusers requires entering the current
password prior to a new password. The user cannot enter a password that will
match `'*'` and therefore the account remains password-less.
 
Keep in mind that the git user must have access to the system so please review
your security settings at `/etc/security/access.conf` and make sure the git user
Keep in mind that the git user must have access to the system so please review
your security settings at `/etc/security/access.conf` and make sure the git user
is not blocked.
 
### Postgres error 'FATAL: could not create shared memory segment: Cannot allocate memory'
Loading
Loading
@@ -291,10 +291,10 @@ During 'gitlab-ctl reconfigure' we set and install several sysctl
tweaks to improve Postgres performance and increase connection limits.
This can only be done with root access.
 
### gitlab-rake assets:precompile fails with 'Permission denied'
### gitlab-rake gitlab:assets:compile fails with 'Permission denied'
 
Some users report that running `gitlab-rake assets:precompile` does not work
with the omnibus packages. The short answer to this is: do not run that
Some users report that running `gitlab-rake gitlab:assets:compile` does not
work with the omnibus packages. The short answer to this is: do not run that
command, it is only for GitLab installations from source.
 
The GitLab web interface uses CSS and JavaScript files, called 'assets' in Ruby
Loading
Loading
@@ -305,21 +305,21 @@ you are a normal user of GitLab, you do not want these files to be in the
developer friendly format however because that makes GitLab slow. This is why
part of the GitLab setup process is to convert the assets from a
developer-friendly format to an end-user friendly (compact, fast) format; that
is what the `rake assets:precompile` script is for.
is what the `rake gitlab:assets:compile` script is for.
 
When you install GitLab from source (which was the only way to do it before we
had omnibus packages) you need to convert the assets on your GitLab server
every time you update GitLab. People used to overlook this step and there are
still posts, comments and mails out there on the internet where users recommend
each other to run `rake assets:precompile`. With the omnibus packages things
are different: when we build the package [we convert the assets for
you](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/1cfe925e0c015df7722bb85eddc0b4a3b59c1211/config/software/gitlab-rails.rb#L74).
each other to run `rake assets:precompile` (which has now been renamed
`gitlab:assets:compile`). With the omnibus packages things are different: when
we build the package [we compile the assets for you](https://gitlab.com/gitlab-org/omnibus-gitlab/blob/1cfe925e0c015df7722bb85eddc0b4a3b59c1211/config/software/gitlab-rails.rb#L74).
When you install GitLab with an omnibus package, the converted assets are
already there! That is why you do not need to run `rake assets:precompile` when
you install GitLab from a package.
already there! That is why you do not need to run `rake gitlab:assets:compile`
when you install GitLab from a package.
 
When `gitlab-rake assets:precompile` fails with a permission error it fails for
a good reason from a security standpoint: the fact that the assets cannot
When `gitlab-rake gitlab:assets:compile` fails with a permission error it fails
for a good reason from a security standpoint: the fact that the assets cannot
easily be rewritten makes it harder for an attacker to use your GitLab server
to serve evil JavaScript code to the visitors of your GitLab server.
 
Loading
Loading
@@ -327,10 +327,10 @@ If you want to run GitLab with custom JavaScript or CSS code you are probably
better off running GitLab from source, or building your own packages.
 
If you really know what you are doing,
you can execute `gitlab-rake assets:precompile` like this
you can execute `gitlab-rake gitlab:assets:compile` like this
 
```shell
sudo NO_PRIVILEGE_DROP=true USE_DB=false gitlab-rake assets:clean assets:precompile
sudo NO_PRIVILEGE_DROP=true USE_DB=false gitlab-rake gitlab:assets:clean gitlab:assets:compile
# user and path might be different if you changed the defaults of
# user['username'], user['group'] and gitlab_rails['dir'] in gitlab.rb
sudo chown -R git:git /var/opt/gitlab/gitlab-rails/tmp/cache
Loading
Loading
Loading
Loading
@@ -34,14 +34,6 @@ be installed under a relative URL, for example `https://example.com/gitlab`.
Note that by changing the URL, all remote URLS will change, so you'll have to
manually edit them in any local repository that points to your GitLab instance.
 
### Relative URL requirements
The Omnibus GitLab package is shipped with pre-compiled assets (CSS, JavaScript,
fonts, etc.). If you configure Omnibus with a relative URL, the assets will
need to be recompiled, which is a task which consumes a lot of CPU and memory
resources. To avoid out-of-memory errors, you should have at least 2GB of RAM
available on your system, while we recommend 4GB RAM, and 4 or 8 CPU cores.
### Enable relative URL in GitLab
 
Follow the steps below to enable relative URL in GitLab:
Loading
Loading
@@ -91,23 +83,6 @@ sudo gitlab-ctl restart unicorn
If you stumble upon any issues, see the [troubleshooting section]
(#relative-url-troubleshooting).
 
### Relative URL troubleshooting
If for some reason the asset compilation fails (i.e. the server runs out of memory),
you can execute the task manually after you addressed the issue (e.g. add swap):
```shell
sudo NO_PRIVILEGE_DROP=true USE_DB=false gitlab-rake assets:clean assets:precompile
sudo chown -R git:git /var/opt/gitlab/gitlab-rails/tmp/cache
```
User and path might be different if you changed the defaults of
`user['username']`, `user['group']` and `gitlab_rails['dir']` in `gitlab.rb`.
In that case, make sure that the `chown` command above is run with the right
username and group.
[590]: https://gitlab.com/gitlab-org/omnibus-gitlab/merge_requests/590 "Merge request - Relative url support for omnibus installations"
## Loading external configuration file from non-root user
 
Omnibus-gitlab package loads all configuration from `/etc/gitlab/gitlab.rb` file.
Loading
Loading
Loading
Loading
@@ -214,7 +214,6 @@ templatesymlink "Create a relative_url.rb and create a symlink to Rails root" do
group "root"
mode "0644"
variables(node['gitlab']['gitlab-rails'].to_hash)
notifies [:run, 'bash[generate assets]']
restarts dependent_services
 
unless node['gitlab']['gitlab-rails']['gitlab_relative_url']
Loading
Loading
@@ -331,7 +330,6 @@ end
# Or migration failed for some reason
remote_file File.join(gitlab_rails_dir, 'REVISION') do
source "file:///opt/gitlab/embedded/service/gitlab-rails/REVISION"
notifies :run, 'bash[generate assets]' if node['gitlab']['gitlab-rails']['gitlab_relative_url']
end
 
# If a version of ruby changes restart unicorn. If not, unicorn will fail to
Loading
Loading
@@ -354,20 +352,6 @@ execute "clear the gitlab-rails cache" do
action :nothing
end
 
bash "generate assets" do
code <<-EOS
set -e
/opt/gitlab/bin/gitlab-rake assets:clean assets:precompile
chown -R #{gitlab_user}:#{gitlab_group} #{gitlab_rails_tmp_dir}/cache
EOS
# We have to precompile assets as root because of permissions and ownership of files
environment ({ 'NO_PRIVILEGE_DROP' => 'true', 'USE_DB' => 'false' })
dependent_services.each do |sv|
notifies :restart, sv
end
action :nothing
end
bitbucket_keys = node['gitlab']['gitlab-rails']['bitbucket']
 
unless bitbucket_keys.nil?
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment