I have the following issue with my Eslint and docker when I add a new dependency to the project I must add it in my local environment and inside the docker with npm install or yarn add, Right now I am working on a project with next js, so, Eslint is setting up by nextjs installing. Also, I have Visual Code such as Code Editor.
I'm going to share with you my configuration docker files:
Dockerfile
FROM node:16.17.0-alpine as xxx-xxx
WORKDIR /home/node/app
COPY package*.json ./
RUN yarn
COPY . .
CMD ["yarn", "dev"]
docker-compose.yml
version: '3.7'
services:
mongo:
image: mongo:5.0.12-focal
container_name: mongodb_xxx_xxx
restart: unless-stopped
env_file: .env
environment:
- MONGO_INITDB_ROOT_USERNAME=$MONGO_USERNAME
- MONGO_INITDB_ROOT_PASSWORD=$MONGO_PASSWORD
ports:
- '27017:27017'
volumes:
- dbdata:/data/db
ts-node-docker:
build:
context: .
dockerfile: Dockerfile
target: xxx-xxx
image: node:16.17.0-alpine
container_name: nodejs_xxx-xxx
restart: unless-stopped
env_file: .env
environment:
- MONGO_USERNAME=$MONGO_USERNAME
- MONGO_PASSWORD=$MONGO_PASSWORD
- MONGO_HOSTNAME=$MONGO_HOSTNAME
- MONGO_PORT=$MONGO_PORT
- MONGO_DB=$MONGO_DB
volumes:
- .:/home/node/app
- ./nodemon.json:/home/node/app/nodemon.json
- ./tsconfig.json:/home/node/app/tsconfig.json
- /home/node/app/node_modules
expose:
- '80'
ports:
- '80:8080'
depends_on:
- mongo
volumes:
dbdata:
.eslintrc.json
{
"extends": "next/core-web-vitals"
}