Next.js Discord

Discord Forum

Next.js & Docker - watching file changes

Unanswered
v.. posted this in #help-forum
Open in Discord
Avatar
v..OP
I'm aiming to contain my Next.js app with file syncing via Docker watch (hence the other tag on this post) and while I am containing the project, I'm not getting the benefits of Docker watch syncing my files to the containers files and re-building in real time, see below

Dockerfile
FROM node:18-alpine

WORKDIR /app
COPY package*.json ./
RUN npm install

COPY . .
EXPOSE 3000
CMD npm run dev


compose.yaml
services:
  app:
    build:
      context: .
    image: nextjs-template
    ports:
      - "3000:3000"
    environment:
      NODE_ENV: development
    develop:
      watch:
        - action: sync
          path: ./src
          target: /src/app
          ignore:
            - node_modules/
        - action: rebuild
          path: package.json


The container is spun up and I do see my next app as I'd expect it, but any changes made thereafter aren't reflected as I'm aiming for.

See attached project structure for further context
Image

3 Replies

Avatar
v..OP
I'm on Windows 10 and read some things about file syncing not working unless I use WSL? Looking into that now
I also posted this on Docker forum with no replies