I am trying build a good workflow to work with docker and nodejs
I think that I have a good base, but I can not get the package-lock.json generated inside my container to my source code even though I have a defined volume
this is my Dockerfile:
FROM node
WORKDIR /app
COPY ./package.json ./
RUN npm install
RUN npm install -g nodemon
COPY ./src ./src
EXPOSE 3000
CMD ["nodemon", "./src/index.js"]
and this is my docker-compose.yml:
version: '3'
services:
web:
build: ./app
command: nodemon ./src/index.js
ports:
- '8080:3000'
volumes:
- ./app/src:/app/src
- /app/node_modules/
links:
- mysql
mysql:
image: mysql:5.6
environment:
- MYSQL_DATABASE=dev
- MYSQL_USER=dev
- MYSQL_PASSWORD=dev
- MYSQL_ROOT_PASSWORD=dev
ports:
- '3306:3306'
In order to commit the package-lock.json to my version control tool, everytime I install a new package through npm install
inside my container and a package-lock.json is generated/updated, I wanna move on to my source code the generated package-lock.json file