Combining ADD and VOLUME on a nodejs Dockerfile I have a node project. My scripts section of package.json looks like this:

"scripts": {
  "postinstall": "gulp",
  "start": "node index.js",
  "test": "node ./node_modules/mocha/bin/mocha test"
},


My Dockerfile looks like this

FROM node:6.11-alpine

RUN mkdir -p /code
ADD . /code
WORKDIR /code
VOLUME /code

RUN npm install -g -s --no-progress yarn &amp;&amp; \
    yarn &amp;&amp; \
    yarn run test &amp;&amp; \
    yarn cache clean


My docker-compose.yml looks like this:

version: "3"

services:
  web:
    build: .
    volumes:
      - .:/code
    command: "npm start"
    ports:
      - "8080:8080"
    networks:
      - internal

networks:
  internal:


This combination of ADD and VOLUME seems to give me what I need in terms of the javascript being there during the build stage and changes getting picked up in real time. However, I'm scared I'm doing something terribly wrong.
This Dockerfile should contain:

FROM node:6.11-alpine

COPY . /code
WORKDIR /code

RUN npm install -g -s --no-progress yarn &amp;&amp; \
    yarn &amp;&amp; \
    yarn run test &amp;&amp; \
    yarn cache clean

EXPOSE 8080

CMD ["npm", "start"]


COPY copies your current directory to /code for building the final image (that holds compiled code normally).

In your docker-compose.yml, mounting a volume is used for your dev purposes, so that the files modified replace the ones on your image.

version: "3"

services:
  web:
    build: .
    volumes:
      - .:/code
    command: "npm run start:dev"
    ports:
      - "8080:8080"
    networks:
      - internal

networks:
  internal: