Home | Blogs | TILs | Papers | Projects | Writings | Books | Astro |
I was trying to get the HRM working in the docker environment today. What I forgot is how the webpacker try to resolv the webpacker server, which is not obvious in non-docker environment. Few of the points that I learned:
docker-compose.yml
as well as in webpacker.yml
. Websocket is initialised with these values.bin/webpack-dev-server
public
and host
configuration in dev_server
in webpacker.yml
are two different things.public/packs
).This was the final configuration that I had to get it up and running:
docker-compse.yml
services:
webpacker:
build: .
command: bash -c "rm -rf /myapp/public/packs; /myapp/bin/webpack-dev-server"
volumes:
- .:/myapp
ports:
- "3035:3035"
db:
image: postgres:9.6
ports:
- "5432"
app:
build: .
command: bash -c "rm /myapp/tmp/pids/server.pid; bundle exec rails server -p 3000 -b '0.0.0.0'"
volumes:
- .:/myapp
ports:
- "3000:3000"
depends_on:
- webpacker
- postgres
dev_server
section in webpacker.yml
dev_server:
https: false
host: webpacker # <-- this is the key
port: 3035
public: 0.0.0.0:3035
hmr: true
# Inline should be set to true if using HMR
inline: true
overlay: true
disable_host_check: true
use_local_ip: false
A docker-compose up
will start the web server along with the webpacker sever that will watch for change and pass it via a websocket to the frontend which will get automatically reloaded after the diff got compiled.
Very fast!