Dockerで環境構築したExpressにNodemonをインストールしてみました。
terminal
1docker-compose up --build
で立ち上げ後にファイルを編集してもNodemonが機能せず、即時反映されません。
どうしたら機能しますか?
ディレクトリ構造
my-app |-docker-compose.debug.yml |-docker-compose.yml |-app |-bin |-node_modules |-public |-routes |-views |-app.js |-Dockerfile |-package-lock.json |-package.json
docker-compose.yml
yml
1version: '3.4' 2 3services: 4 app: 5 image: dockerexpress 6 build: 7 context: app 8 dockerfile: ./Dockerfile 9 ports: 10 - 3000:3000 11
Dockerfile
FROM node:12.18-alpine WORKDIR /usr/src/app COPY ["package.json", "package-lock.json*", "npm-shrinkwrap.json*", "./"] RUN npm install COPY . . EXPOSE 3000 CMD ["npm", "start"]
package.json
{ "name": "app", "version": "0.0.0", "private": true, "scripts": { "start": "nodemon ./bin/www" }, "dependencies": { "cookie-parser": "~1.4.4", "debug": "~2.6.9", "ejs": "~2.6.1", "express": "~4.16.1", "express-session": "^1.17.1", "http-errors": "~1.6.3", "morgan": "~1.9.1", "nodemon": "^2.0.7", "oauth": "^0.9.15", "passport": "^0.4.1", "passport-twitter": "^1.0.4", "twitter": "^1.7.1" } }