0

I am trying to set up a development environment on docker. I am running code that I made from this project.

I have seem several answers on stack-overflow but none of them solves my issue.

My package.json script is as below.

"ng": "ng",
"serve": "node server",
"start": "concurrently -c \"yellow.bold,green.bold\" -n \"SERVER,BUILD\" \"nodemon --legacy-watch ./server/index.js\" \"ng build --watch\"",
"build": "ng build --prod",
// more code...

My Dockerfile looks like this:

WORKDIR /usr/src/app

COPY package*.json ./

RUN npm install -g --force nodemon

RUN npm install

COPY . .

EXPOSE 4043

CMD ["npm", "start"]

My docker-compose.yml file looks as below:

services:
    app:
        container_name: express-ng-server
        restart: always
        image: express-ng-server-image
        build: .
        ports: 
            - '80:4043'
        expose:
            - 4043

When I do docker-compose up nodemon does react to code changes.

When I run npm start nodemon works as expected.

What am I doing wrong? How can I get nodemon to work in docker?

I am using the latest version of nodemon "nodemon": "^2.0.4",

2
  • 1
    The code won't change unless you rebuild the image, and if you rebuild the image you'll need to recreate the container. I would only use tools like nodemon in a local-development environment, and not with Docker.
    – David Maze
    Commented Sep 6, 2020 at 10:59
  • I was rebuilding the container with docker-compose build. But it still did not work. I guess I will follow your way of using nodemon; only in a local development environment and not with docker.
    – YulePale
    Commented Sep 6, 2020 at 12:32

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.