我正在尝试使用Docker容器中的Passenger(v5.1.4)+ Nginx设置rails(v4.2.6)应用程序。 我使用官方ruby 2.3.1作为基本图像。
以下是我的网站nginx文件
server {
server_name example.local;
listen 4000;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
root /www/app/public;
passenger_ruby /usr/local/bin/ruby;
try_files $uri @passenger;
location @passenger {
passenger_enabled on;
rails_env development;
}
...
}
passenger_pre_start http://0.0.0.0:4000/status;
更多背景信息:
/usr/local/bin/ruby
/usr/local/bundle
但是当我启动nginx服务时,我收到以下错误
It looks like Bundler could not find a gem. Maybe you didn't install all the gems that this application needs. To install your gems, please run:
bundle install
If that didn't work, then the problem is probably caused by your application being run under a different environment than it's supposed to. Please check the following:
乘客无法找到应用宝石,因为GEM_HOME和GEM_PATH设置错误
我尝试在docker-entrypoint中手动设置环境变量GEM_HOME
和GEM_PATH
以更正gem路径,即/usr/local/bundle
。然而它不起作用。
如何让乘客使用正确的宝石套装。
注意:我没有使用rvm
提前致谢
答案 0 :(得分:1)
此问题的原因是user_sandboxing by passenger
由于我的app目录由root拥有,而且我在nginx中没有配置passenger_default_user
,因此乘客正在以用户nobody
和群组nogroup
我通过将我的app目录的所有者更改为非root用户来修复此问题。
注意:我也不得不使用rvm而不是ruby:2.3.1基本图像。