I’m working a large legacy application and we recently updated to Rails 4.2 from 3.2. After the switch, Rails, inside the docker container, isn’t picking up changes made from outside the container. Restarting the docker container then picks up the changes. It is getting tiresome to restart docker every time I make a change. I’ve searched everywhere and found many instances of this issue, with possible solutions but nothing has worked. Touching a file from within a docker bash shell does trigger Rails to reload. File events are not being passed through to the docker container.
Some of the failed efforts:
- adding
config.file_watcher = ActiveSupport::FileUpdateChecker
- updating Docker for Mac to current version
3.1.0
We have devs on both Catalina and Big Sur and both experience the same issue.
docker-compose.yml
worker: &base
build: .
image: myapp/app4
command: bash -c "source /root/.profile && dockerize -wait tcp://mysql:3306 -wait tcp://redis:6379 -timeout 60s rake jobs:work"
env_file:
- ./config/envvars/mysql.env
- ./config/envvars/ruby.env
- ./config/envvars/private.env
volumes:
- "nfsmount4:/usr/src/app"
- ./config/mysql_client.cnf:/etc/my.cnf
- $HOME/.ssh:/root/.ssh
links:
- mysql
- redis
volumes:
mysql-data4:
nfsmount4:
driver: local
driver_opts:
type: nfs
o: addr=host.docker.internal,rw,nolock,hard,nointr,nfsvers=3
device: ":/System/Volumes/Data/${PWD}"
2
Answers
This is a wild guess, but has happened before and might be related to issue posted on here.
The problem might be simply on the syncing of the time between your host system and container. I have personally had some time issues on containers with Mac.
There is also related SO post in here.
in production.rb the default seem to be to read the code just once. You may need to turn off some caching to have dynamic reloads. If not the files are updated both outside and inside the container, but rails does not care.
You may need to set one or more of these to false? But it may impact your performance. Compare with development.rb