В доступе отказано @ rb_sysopen - log/application.log (Errno::EACCES)

Привет, я использую Docker для развертывания моего приложения rails, используя образ phusion/passenger. Вот мой Dockerfile:

FROM phusion/passenger-ruby22:0.9.19

# set correct environment variables
ENV HOME /root
ENV RAILS_ENV production

# Use baseimage-docker's init system.
CMD ["/sbin/my_init"]

# Expose Nginx HTTP service
EXPOSE 80

# Start Nginx / Passenger
RUN rm -f /etc/service/nginx/down

# Remove the default site
RUN rm /etc/nginx/sites-enabled/default

# Add the nginx site and config
ADD nginx.conf /etc/nginx/sites-enabled/nginx.conf
ADD rails-env.conf /etc/nginx/main.d/rails-env.conf

# Let ensure these packages are already installed
# otherwise install them anyways
RUN apt-get update && apt-get install -y build-essential \
                                         nodejs \
                                         libpq-dev

# bundle gem and cache them
WORKDIR /tmp
ADD Gemfile /tmp/
ADD Gemfile.lock /tmp/
RUN gem install bundler
RUN bundle install

# Add rails app
ADD . /home/app/webapp
WORKDIR /home/app/webapp


RUN touch log/delayed_job.log log/production.log log/

RUN chown -R app:app /home/app/webapp
RUN RAILS_ENV=production rake assets:precompile

# Clean up APT and bundler when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

Я получаю разрешение на tmp а также log файлы.

web_1 | [ 2016-07-19 08:45:12.6653 31/7ff812726700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /home/app/webapp: An error occurred while starting up the preloader.
web_1 |   Error ID: 42930e85
web_1 |   Error details saved to: /tmp/passenger-error-9DeJ86.html
web_1 |   Message from application: Permission denied @ rb_sysopen - log/logentries.log (Errno::EACCES)
web_1 |   /usr/lib/ruby/2.2.0/logger.rb:628:in `initialize'
web_1 |   /usr/lib/ruby/2.2.0/logger.rb:628:in `open'
web_1 |   /usr/lib/ruby/2.2.0/logger.rb:628:in `open_logfile'
web_1 |   /usr/lib/ruby/2.2.0/logger.rb:584:in `initialize'
web_1 |   /usr/lib/ruby/2.2.0/logger.rb:318:in `new'
web_1 |   /usr/lib/ruby/2.2.0/logger.rb:318:in `initialize'
web_1 |   /var/lib/gems/2.2.0/gems/le-2.7.2/lib/le/host/http.rb:37:in `new'
web_1 |   /var/lib/gems/2.2.0/gems/le-2.7.2/lib/le/host/http.rb:37:in `initialize'

Я пытался дать chmod -R 665/775/777 log/ и до сих пор не решил проблему.

Спасибо

1 ответ

Переставь свою линию RUN RAILS_ENV=production rake assets:precompile будет первый RUN chown -R app:app /home/app/webapp(после задания с граблями) Итак, должно быть что-то вроде этого:

RUN RAILS_ENV=production rake assets:precompile RUN chown -R app:app /home/app/webapp

Другие вопросы по тегам