Despite there are a lot of Q/A on internet I couldn't find anything that would fix me the issue that running a simple express
js app, won't refresh on changes when running it inside Docker.
Here's my Dockerfile
FROM node:16-alpine3.11
WORKDIR /var/be_core
VOLUME /var/be_core
COPY package*.json ./
RUN npm install
COPY . .
CMD ["npm", "start"]
The docker-compose.yml
version: '3.9'
volumes:
be_core_volume:
services:
be_server_core:
ports:
- "9000:3000"
image: jeko/be_server_core
environment:
- BE_SERVER_CORE_PORT=3000
volumes:
- "be_core_volume:/var/be_core"
The js server, really simple:
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send("Hello world");
});
const PORT = process.env.BE_SERVER_CORE_PORT || 3000;
app.listen(PORT, () => {
console.log(`Core server running on internal port : ${PORT}`);
});
the command npm start
simply run that
"scripts": {
"start": "nodemon -L ./server.js"
}
If I run the server as a stand alone process (not within a docker container) it works perfectly.
using the command docker-compose up
- instead - seems to works fine, since it starts everything, but when changing something in the server.js
file, it doesn't refresh.
What am I doing wrong?