middleman / middleman-livereload

LiveReload support for Middleman
http://middlemanapp.com
MIT License
117 stars 39 forks source link

Livereload not responding to files updated by host editor in VM setup #99

Closed laurencefass closed 6 years ago

laurencefass commented 6 years ago

I am running a node js application in a docker container in a virtualbox VM running on a windows 10 host.

The only way i can get livereload to reload is if i modify files from within the container (docker exec -it....) This doesnt actually reload the browswer only gives a terminal debug message (with -d option).

This doesnt appear to work at all if i make changes from the docker vm, or from the host.

would be great to get livereload workiing between host and container. any pointers much appreciated.

thanks

sandstrom commented 6 years ago

@laurencefass No immediately idea on how to solve that, sorry!

If you think there is a bug in middleman-reload, a great place to start is to try to hunt down the bug and then make a fix for it, and submit that as a PR.

Since this is open-source there is no one employed to work on it, so everyone must chip in.

I'll close this issue for now, but happy to review a PR if you find a solution.

LimeBlast commented 5 years ago

For anyone that's interested, I think I've fixed this issue.

I made sure the livereload port was shared between the container and the host via the docker-compose.yml file, and updated the config.rb file to pass in a host of 0.0.0.0:

# Dockerfile
FROM ruby:2.5.1

RUN apt-get update -qq && apt-get install -y \
    nodejs                                   \
    build-essential

ENV APP_HOME /usr/src/app

WORKDIR $APP_HOME
COPY Gemfile* $APP_HOME/
RUN bundle install

COPY . $APP_HOME/

EXPOSE 4567
CMD ["middleman", "server"]
# docker-compose.yml
version: '3'
services:
  web:
    build: .
    image: middleman
    command: ['middleman', 'server']
    volumes:
      - .:/usr/src/app:cached
    ports:
      - "4567:4567"
      - "35729:35729"
# config.rb
...
configure :development do
  activate :livereload, host: '0.0.0.0'
end
...

I've not done any extensive testing of this, but it seems to work for me.