Reputation: 23
I'm trying to run a RoR project without root user on docker. I'm using the official ruby image and when I execute bundle install
with a non root user everything goes okay, but when I run rails s -b '0.0.0.0'
or bundle exec rails s -b '0.0.0.0'
I get this error:
/usr/local/bundle/gems/bootsnap-1.3.2/lib/bootsnap/compile_cache/iseq.rb:37:in `fetch': Permission denied - bs_fetch:atomic_write_cache_file:open (Errno::EACCES)
Here is my Dockerfile:
FROM ruby:2.6.3
COPY controleGarrafao/ /home/docker/controleGarrafao
RUN apt-get update -qq && apt-get install sudo
WORKDIR /home/docker/controleGarrafao
RUN chmod +x /usr/bin/docker_entrypoint.sh
RUN chmod 777 /usr/local/bin/bundle
RUN useradd -m docker && echo "docker:docker" | \
chpasswd
RUN echo "docker ALL=(ALL:ALL) NOPASSWD: ALL" | \
tee -a /etc/sudoers
RUN chmod 777 /home/docker
USER docker
RUN bundle install
EXPOSE 3000
Can someone help me with this?
Upvotes: 2
Views: 2578
Reputation: 5037
It seems like the problem is with the gem bootsnap
as your error message indicates.
If you look in the bootsnap documentation you see this:
Note that bootsnap writes to tmp/cache, and that directory must be writable. Rails will fail to boot if it is not. If this is unacceptable (e.g. you are running in a read-only container and unwilling to mount in a writable tmpdir), you should remove this line or wrap it in a conditional.
"this line" refers to require 'bootsnap/setup'
in config/boot.rb
So you either need to make sure the tmp/cache directory is writeable in your container or remove the the bootsnap line from config/boot.rb
Upvotes: 4