Next.js Discord

Discord Forum

HMR not working correctly in docker enviroment?

Unanswered
Pacific saury posted this in #help-forum
Open in Discord
Pacific sauryOP
i am using nginx docker setup for next js . I am unsure what i am doing wrong?
After building i just install next js and build using pnpm dev
but hmr doesn't work

docker-compose.yml
services:
  nginx:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "80:80"
      - "3000:3000"
      - "5555:5555"
    volumes:
      - ./nginx/conf:/etc/nginx/conf.d
      - ./app/:/usr/share/nginx/html
    tty: true
    stdin_open: true


i did try to add develop watch docker configuration. I am not getting it right.

and for Dockerfile
# Dockerfile

FROM nginx:latest

# Install necessary packages: curl, gnupg2, git, zip, unzip
RUN apt-get update && \
    apt-get install -y \
        curl \
        gnupg2 \
        git \
        zip \
        unzip && \
    # Add Node.js repository
    curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
    # Install Node.js
    apt-get install -y nodejs && \
    # Install pnpm globally using npm
    npm install -g pnpm && \
    # Clean up to reduce image size
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Set the working directory to /usr/share/nginx/html
WORKDIR /usr/share/nginx/html

# Copy custom Nginx configuration
COPY ./nginx/conf/default.conf /etc/nginx/conf.d/

# Copy application files into the working directory
COPY ./app/ .

# Expose port 80

EXPOSE 80

# Start Nginx in the foreground
CMD ["nginx", "-g", "daemon off;"]

0 Replies