Next js - Docker
Unanswered
Lesser Frigatebird posted this in #help-forum
Lesser FrigatebirdOP
My problem is that if I am in the dev environment and make changes the changes does not sync, for the changes to reflect I have to docker compose down and then docker compose up.
This is my docker-compose.yml file
services:
client-dev:
build:
context: .
dockerfile: Dockerfile.dev
ports:
- "3000:3000"
volumes:
- .:/app
- /app/node_modules
environment:
- WATCHPACK_POLLING=true
client-prod:
build:
context: .
dockerfile: Dockerfile.prod
ports:
- "4000:4000"
env_file:
- .env
This is my Dockerfile.dev
FROM node:latest
WORKDIR /app
COPY package.json ./
COPY . .
RUN npm install
EXPOSE 3000
CMD ["npm", "run", "dev"]
This is my Dockerfile.prod
FROM node:latest
WORKDIR /app
COPY package.json .
COPY . .
RUN npm install
RUN npm run build
ENV PORT=4000
EXPOSE 4000
CMD ["npm", "run", "start"]
This is my docker-compose.yml file
services:
client-dev:
build:
context: .
dockerfile: Dockerfile.dev
ports:
- "3000:3000"
volumes:
- .:/app
- /app/node_modules
environment:
- WATCHPACK_POLLING=true
client-prod:
build:
context: .
dockerfile: Dockerfile.prod
ports:
- "4000:4000"
env_file:
- .env
This is my Dockerfile.dev
FROM node:latest
WORKDIR /app
COPY package.json ./
COPY . .
RUN npm install
EXPOSE 3000
CMD ["npm", "run", "dev"]
This is my Dockerfile.prod
FROM node:latest
WORKDIR /app
COPY package.json .
COPY . .
RUN npm install
RUN npm run build
ENV PORT=4000
EXPOSE 4000
CMD ["npm", "run", "start"]