webpack-rails icon indicating copy to clipboard operation
webpack-rails copied to clipboard

Example Docker setup

Open c-lliope opened this issue 9 years ago • 2 comments

I wanted to provide my setup with webkit-rails and Docker – if possible, it would be nice to add some of this to the README.

Sample docker-compose.yml file. Note the -b and --host options, which expose the server processes to the host machine.

services:
  webpack:
    env_file: .env
    image: assemble/web
    command: /app/node_modules/.bin/webpack-dev-server --config config/webpack.config.js --host 0.0.0.0
    volumes:
      - .:/app
    ports:
      - 8888:8888

  web:
    build: .
    command: bundle exec rails s -p 3000 -b 0.0.0.0
    ports:
      - "$PORT:3000"
    links:
      - db
      - webpack
    volumes:
      - .:/app

Be sure to set the manifest_host to match the name of the docker-compose webpack service.

# config/application.rb
    config.webpack.dev_server.manifest_host = 'webpack'
    config.webpack.dev_server.manifest_port = 3808
    config.webpack.dev_server.port = 3808

When webpack runs inside a Docker container, it cannot observe the file change events that it needs to re-compile the assets. As a workaround, add to your webpack config:

// config/webkit.config.js
  watchOptions: {
    poll: true
  }

c-lliope avatar Jan 31 '17 02:01 c-lliope

When webpack runs inside a Docker container, it cannot observe the file change events that it needs to re-compile the assets. As a workaround, add to your webpack config:

@graysonwright Are you on OS X? I think this is a limitation of docker for mac but not of docker itself as I've been running webpack on docker for a few months now and I don't need that setting.

bpinto avatar Feb 01 '17 15:02 bpinto

ah, I think you're right. IIRC, it's an issue with Virtualbox so it affects users running Docker on OS X and Windows.

c-lliope avatar Feb 16 '17 20:02 c-lliope