GithubHelp home page GithubHelp logo

demyxsh / browsersync Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 1.0 117 KB

Non-root Docker image running Alpine Linux, Node.js, and BrowserSync.

License: MIT License

Dockerfile 54.43% Shell 45.57%
alpine-linux browsersync demyx docker nodejs

browsersync's People

Contributors

demyxco avatar github-actions[bot] avatar

Watchers

 avatar

Forkers

proteo

browsersync's Issues

Help with odd issue!

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.