gitlab rake assets:预编译RAILS_ENV=生产失败,出现Permission错误



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

现在我尝试以子目录样式运行GitLab,例如http://url/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)

我该怎么办?

这篇文章描述了一个很好的解决方法。与用户Perceval FARAMAZ建议的类似,我们可以临时打开权限以编译新的和更改的资产,然后再次关闭它们。

通过使用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

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

chmod -R 1777 /opt/gitlab/embedded/service/gitlab-rails/public/assets帮我搞定了。

它为每个人设置了完全读/写/执行的权限,并在"t"上设置了粘性位(除了root/文件所有者之外,没有人可以删除目录,因此允许rake做它的事情)。

首先,直接更改文件会导致它们在reconfigure之后被重写。当调用gitlab-rake时,您不必声明RAILS_ENV,它由gitlab-rake包装器负责。

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

相关内容

最新更新