gitlab-rake assets:precompile RAILS_ENV=生产失败并出现权限错误

gitlab-rake assets:precompile RAILS_ENV=production fails with Permission error

我在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)

我该怎么办?

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

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

chmod -R 1777 /opt/gitlab/embedded/service/gitlab-rails/public/assets 对我有用。

它为每个人设置完全 read/write/execute 的权限,并在 't' 上设置粘性位(除了 root/the 文件所有者之外,没有人可以删除目录,因此允许 rake 做它的东西)。

This post describes a nice workaround. Similar to what 我们可以暂时打开编译新的和修改过的资源的权限,然后再关闭。

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

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