demyxsh / browsersync Goto Github PK
View Code? Open in Web Editor NEWNon-root Docker image running Alpine Linux, Node.js, and BrowserSync.
License: MIT License
Non-root Docker image running Alpine Linux, Node.js, and BrowserSync.
License: MIT License
Hi. I've spent the last few hours pulling my hair trying to figure out what's going on with my setup and finally gave up, so I thought somebody here could give me a hand.
I'm using the following docker-compose.yml file:
version: '2'
services:
web:
container_name: ${DOMAIN_KEY}
image: nginx
volumes:
- ./html:/var/www/html
labels:
- 'traefik.enable=true'
- "traefik.http.routers.${DOMAIN_KEY}-http.rule=Host(`www.${DOMAIN_KEY}.test`)"
- "traefik.http.routers.${DOMAIN_KEY}-http.entrypoints=http"
expose:
- 80
networks:
- dockernet
browsersync:
container_name: ${DOMAIN_KEY}_bs
image: demyx/browsersync
environment:
BROWSERSYNC_PROXY: http://www.${DOMAIN_KEY}.test
BROWSERSYNC_DOMAIN_SOCKET: http://bs.${DOMAIN_KEY}.test
BROWSERSYNC_FILES: "[\"/var/www/html/assets/css/*.css\"]"
BROWSERSYNC_PORT: 3000
BROWSERSYNC_PATH: "false"
BROWSERSYNC_PREFIX: "false"
volumes_from:
- web
expose:
- 3000
labels:
- "traefik.enable=true"
- "traefik.http.routers.${DOMAIN_KEY}-bs.rule=(Host(`bs.${DOMAIN_KEY}.test`))"
- "traefik.http.routers.${DOMAIN_KEY}-bs.entrypoints=http"
networks:
- dockernet
networks:
dockernet:
external: true
This gives me two working containers, my web app at http://www.site.test and another with BrowserSync at http://bs.site.test. Everything seems OK with the BrowserSync container, I can see the proxy site and the "BrowserSync: connected" badge at the top of the page when I open it in the browser. But here's the thing: I can't make it reload files automatically when they're changed.
I use two computers for my development work: my workstation is an iMac where all the files are stored. A second computer (a Mac Mini) is running Ubuntu Server, which is where Docker is running. Since the actual code files live in the workstation, everything is mounted as a nfs share from the Ubuntu server. From there, Docker containers load volumes as local directories.
So, whenever I make a change in a file from the remote workstation, the change is propagated to the Ubuntu server, and picked up by the Docker volume. This usually works great and gives me no issues whatsoever. But for some reason, it won't trigger the event that makes BrowserSync to recognize that the file has changed.
Obviously, I first checked for errors in paths, etc. But any change from the workstation is being propagated just fine to the server, as usual. When logged in the Ubuntu server I can see how files are modified as soon as I make a change from the workstation.
Now, the funny thing is that if I manually change a file when logged in the server like this:
mini$ touch /users/proteo/sites/html/assets/css/styles.css
The change is detected perfectly by BrowserSync and http://bs.site.test is updated immediately. I can also make the change inside the BrowserSync container, and it also works flawlessly:
mini$ docker exec -ti site-bs /bin/bash
bash-5.0$ touch /var/www/html/assets/css/styles.css
Hope you can give a hint. Thanks in advance!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.