Olá, estou com um problema aonde quando inicio o meu container docker, o nodemon inicia o server.js mas não atualiza o arquivo mais como se ele rodasse o nodemon uma vez só, ou não identificava quando eu salvava o arquivo.
Segue os arquivo do docker-compose, image do docker e o package.json
Docker-Compose
version: '3.4'
services:
dev:
build: .
container_name: livraria_api_dev
command: npm run dev
working_dir: /app
ports:
- "3000:3000"
volumes:
- ./:/app:cached
depends_on:
- db
test:
build: .
container_name: livraria_api_test
command: npm run test
working_dir: /app
ports:
- "4000:4000"
volumes:
- ./:/app:cached
db:
image: postgres
container_name: livraria_db
environment:
- POSTGRES_USER=postgres
- POSTGRES_PASSWORD=admin123
- POSTGRES_DB=livraria_db
ports:
- "5432:5432"
volumes:
- database:/var/lib/postgresql/data
volumes:
database:
Image do Docker
FROM node:18-alpine
ADD . /app
WORKDIR /app
RUN apk add --update-cache sqlite
USER node
CMD npm install
Arquivo package.json
{
"name": "api-js-local",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"migrate": "npx knex --knexfile=./src/db/knexfile.js migrate:latest",
"unmigrate": "npx knex --knexfile=./src/db/knexfile.js migrate:rollback",
"seed": "npx knex --knexfile=./src/db/knexfile.js seed:run",
"dev": "npm install && npm run migrate && npm run seed && nodemon server.js",
"lint": "eslint --fix --ignore-path .gitignore .",
"prepare-test-db": "sqlite3 ./src/test/livraria.sqlite < populate.sql",
"drop-test-db": "rm -f ./src/test/livraria.sqlite",
"test:mocha": "mocha ./src/test/routes/*.test.js",
"test:jest": "node --experimental-vm-modules node_modules/jest/bin/jest.js ./src/test/models/*.test.js --verbose",
"test": "npm rebuild && npm run drop-test-db && export NODE_ENV=test && npm run prepare-test-db && npm run test:mocha && npm run test:jest"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"dotenv": "16.0.3",
"express": "4.18.1",
"knex": "^2.1.0",
"pg": "8.9.0"
},
"devDependencies": {
"@jest/globals": "28.1.2",
"chai": "4.3.7",
"chai-http": "4.3.0",
"eslint": "8.32.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-plugin-import": "2.26.0",
"jest": "29.4.1",
"mocha": "10.2.0",
"nodemon": "2.0.16",
"sqlite": "4.1.1",
"sqlite3": "5.0.8"
}
}
Muito obrigado pela atenção