Has anyone dealt with syncing files with a docker container running nodemon via docker-compose? I’ve done it with PHP, but this Node project explodes when I do that (as opposed to COPY in the Dockerfile)
Dockerfile:
FROM node:latest
WORKDIR /usr/src/app
COPY . /usr/src/app/
EXPOSE 3000
EXPOSE 9229
RUN npm ci
RUN npm install -g nodemon
docker-compose.yml
version: "2"
services:
api:
depends_on:
- mongo
build:
context: ./
dockerfile: ./Dockerfile
container_name: api
command: "npm run debug && tail -f /dev/null"
restart: always
volumes:
- "mongo:/data/db"
networks:
- network
ports:
- "3000:3000"
- "9001:9229"
links:
- mongo
mongo:
container_name: mongo
image: mongo
ports:
- "27017:27017"
networks:
- network
volumes:
mongo:
networks:
network: {}
And part of package.json (for reference):
"scripts": {
"start": "node ./bin/www",
"test": "mocha ./tests/controllers/*.test.js --timeout 10000 --exit",
"debug": "nodemon --inspect=0.0.0.0 server.js",
"build-docs": "node ./swagger.js"
},
Step debugging, etc. and everything else works just fine, but the files are copies in the container (per the Dockerfile
).
When I add something like:
- "./:/usr/src/app"
to the docker-compose.yml
file for the api
container, I get an error for bcrypt.