gitlab rake资产:预编译RAILS\u ENV=生产失败,出现权限错误

gitlab rake资产:预编译RAILS\u ENV=生产失败,出现权限错误,gitlab,Gitlab,我在CentOS 7上安装了GitLab 7.7.2并成功安装 现在我尝试以子目录样式运行GitLab,例如 我查看了这个文件,并按照此说明进行了更改。 /opt/gitlab/embedded/service/gitlab rails/config 然后我预编译并得到错误 # gitlab-rake assets:precompile RAILS_ENV=production I, [2015-02-27T17:35:18.980208 #4864] INFO -- : Writing /o

我在CentOS 7上安装了GitLab 7.7.2并成功安装

现在我尝试以子目录样式运行GitLab,例如

我查看了这个文件,并按照此说明进行了更改。 /opt/gitlab/embedded/service/gitlab rails/config

然后我预编译并得到错误

# gitlab-rake assets:precompile RAILS_ENV=production
I, [2015-02-27T17:35:18.980208 #4864]  INFO -- : Writing /opt/gitlab/embedded/service/gitlab-rails/public/assets/authbuttons/github_32-199ebcd7adccbfe20068d39bfd57e6bf.png
rake aborted!
Errno::EACCES: Permission denied @ rb_sysopen - /opt/gitlab/embedded/service/gitlab-rails/public/assets/authbuttons/github_32-199ebcd7adccbfe20068d39bfd57e6bf.png+

Tasks: TOP => assets:precompile
(See full trace by running task with --trace)

我该怎么办?

首先,直接更改文件将导致在
重新配置后重写文件。调用
gitlab-rake
时,您不必声明
RAILS\u ENV
它由
gitlab-rake
包装器负责


现在,就相对url选项而言,它还没有在omnibus包中实现。

chmod-R 1777/opt/gitlab/embedded/service/gitlab rails/public/assets
帮了我的忙

它为每个人设置完全读/写/执行的权限,并在“t”上设置粘性位(除了root/文件所有者之外,任何人都不能删除目录,从而允许rake完成任务)。

描述了一个很好的解决方法。与此类似,我们可以临时打开权限以编译新的和更改的资产,然后再次关闭它们

通过使用ACL,而不是标准位,这只针对git用户完成,并且没有实际更改来自
root:root的所有权:

# ... hack on CSS ...

# Need to let user `git` write to assets/ because gitlab-rake tries to write
# to it as `git`, while `assets/` is owned by root.
apt-get install acl
setfacl -R -m u:git:rwX /opt/gitlab/embedded/service/gitlab-rails/public/assets/
gitlab-rake assets:precompile RAILS_ENV=production
chmod -R a+rX /opt/gitlab/embedded/service/gitlab-rails/public/assets/

# Remove git's write access
setfacl -R -x u:git /opt

这既适用于添加新映像,也适用于更改现有资产。

我在/opt/gitlab/embedded/cookbooks/gitlab/templates/default中更改了4个文件:gitlab.yml.erb、unicorn.rb.erb、gitlab-shell-config.yml.erb和nginx-gitlab-http.conf.erb。gitlab.yml.erb------添加“相对url\u根:/gitlab”unicorn.rb.erb------添加“ENV['RAILS\u相对url\u根]=”/gitlab“gitlab-shell-config.yml.erb------更改了”gitlab\u url:“/gitlab/”“nginx-gitlab-http.conf.erb------更改了”位置/gitlab{”然后,我重新配置,最终得到了子目录。向所有人开放权限是一个安全问题。在安装/更改后,关闭权限以再次回答,这对我帮助很大。Thx