Hello, it's the third day I'm trying to deal with nodejs and docker for development and production, but there's no way I can make it work. the Dockerizing a Node.js web app guide says "The guide is intended for development" which, in my opinion, is not true, since you can't setup a change monitor for your app's source.
I wrote this simple Dockerfile
FROM node:carbon
WORKDIR /usr/src/app
COPY package*.json ./
ENV PATH=$PATH:/usr/src/app/node_modules/.bin
RUN npm install
# Bundle app source
COPY . .
EXPOSE 3333
USER node
CMD ["node", "server.js"]
Works well with docker-compose.yml
version: '3'
services:
api:
build: ./api
ports:
- 3333
volumes:
- ./api:/usr/src/app
- /usr/src/app/node_modules
command: nodemon -e js,json server.js
But there's no way I can make local changes reflect in the container. docker logs docker_api_1 display a successful init, but no changes watched.
The only way I could make it work, was by installing nodemon package (which doesn't work either, but it has something like a "per-file legacy polling" technique that actually works), but that consumes a lot of memory and feels really slow. Maybe someone here can give a hint about this issue and we can add it to that guide, or any README because, again, in my opinion, server development without anything like a "livereload" feature is painful. Unless there's some better workflow which I'm not aware of? Thanks in advace.
Docker version 17.10.0-ce, build f4ffd25 (win64)
EDIT: Just found this SO question and looks like that's the only solution. The question is quite old though, so I wonder if we can figure out a better way to bind mount with file change events. Probably any script I can run in the host, parallel to docker?
Hello, it's the third day I'm trying to deal with nodejs and docker for development and production, but there's no way I can make it work. the Dockerizing a Node.js web app guide says "The guide is intended for development" which, in my opinion, is not true, since you can't setup a change monitor for your app's source.
I wrote this simple
DockerfileWorks well with
docker-compose.ymlBut there's no way I can make local changes reflect in the container.
docker logs docker_api_1display a successful init, but no changes watched.The only way I could make it work, was by installing
nodemonpackage (which doesn't work either, but it has something like a "per-file legacy polling" technique that actually works), but that consumes a lot of memory and feels really slow. Maybe someone here can give a hint about this issue and we can add it to that guide, or any README because, again, in my opinion, server development without anything like a "livereload" feature is painful. Unless there's some better workflow which I'm not aware of? Thanks in advace.Docker version 17.10.0-ce, build f4ffd25 (win64)
EDIT: Just found this SO question and looks like that's the only solution. The question is quite old though, so I wonder if we can figure out a better way to bind mount with file change events. Probably any script I can run in the host, parallel to docker?