I'm using Docker on windows for development purposes and i'm trying to create a simple workflow for a node.js project.
I followed this tutorial https://nodejs.org/en/docs/guides/nodejs-docker-webapp/ so my Dockerfile looks like this
FROM node:boron
# Create app directory
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json .
# For npm@5 or later, copy package-lock.json as well
# COPY package.json package-lock.json ./
RUN npm install
# Bundle app source
COPY . .
EXPOSE 8080
CMD [ "npm", "start" ]
My "workflow" for each change would look like this
FIRST BUILD
docker build -t thomas/myApp DockerProjects/myApp ; docker run --name app -p 49160:8080 -d thomas/myApp
AFTER EACH CHANGE
docker build -t thomas/myApp DockerProjects/myApp ; docker stop app ; docker rm app ; docker run --name app -p 49160:8080 -d thomas/myApp
I don't want to have hundreds of containers after each change in the project, that's why i'm deleting it before creating another one.
I see several problems:
- Each time there is a change and a new image is build, a new
<none>:<none>image is created. These images have the same weight as the original one. How can I avoid that ? - Can I use nodemon somehow ?
- Can I launch this process automatically each time I change something in the code ?
Docker is quite new for me and i'm still experimenting with it. Thanks