I have setup a project with Rails following the Docker-compose quick start guide, however I’ve run into an issue where live code changes are not reflected in the app and can only be seen upon rebuilding it.
My Dockerfile is as follows:
FROM ruby:2.3.1
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN gem update
RUN mkdir /myapp
WORKDIR /myapp
ADD Gemfile /myapp/Gemfile
ADD Gemfile.lock /myapp/Gemfile.lock
RUN bundle install
ADD . /myapp
My docker-compose.yml is as follows:
version: '2'
services:
db:
image: postgres
environment:
POSTGRES_DB: dev
POSTGRES_USER: user
POSTGRES_PASSWORD: password
web:
build: .
command: bundle exec rails s -p 3000 -b '0.0.0.0'
volumes:
- .:/myapp
ports:
- "3000:3000"
depends_on:
- db
As far as I can tell, I’m mounting the volume correctly, so I’m not sure why it’s not working. Also, I’m not sure if my setup process is correct or not, but I’m simply running docker-compose build (if not built) followed by docker-compose up. This gets the app working, however code changes just don’t show up.
Docker for Windows does not support inotify / filesystem notifications. We’re adding this to the FAQ.
I tried googling briefly to see if there’s a way to force Rails to poll for filesystem changes, but couldn’t find anything. I suspect it’s possible, though.
What’s weird is that certain files are in fact being updated (Views in my
rails app), however other files are not (Controllers in my rails app). I’m
not sure what could be leading to that behaviour either.
Yup, everything works correctly outside of Docker as it should. Just for
whatever reason changes made outside the container are not shown inside it
(unless the container is rebuilt). I’m not sure if my problem is with the
volume mount or not though.
We don’t have a solution in the works right now, I’m afraid. There’s just no simple technical fix that we could adopt and integrate. We’re continuously exploring options, though.
What framework are you using? Is there no polling work-around?
I am having the issue with Ruby on Rails. I have the problem whenever I change the controllers, for some reason whenever I make edits to the views, the changes are reflected.
Hey @friism thanks for your suggestion. I was not aware of the listen gem. When I saw your message I gave it a try but I have not made it work.
So essentially this gem is run on an external script right? And it is continuously looking for changes? Does it matter if I am using Docker on Windows? Do you have any advice?