【发布时间】:2020-07-24 05:54:21
【问题描述】:
我正在尝试对 Next JS 应用程序进行 docker 化以进行开发,但我无法让 docker-compose 模块重新加载 webpack HMR。当我进行更改时,检测并重新加载大约需要一分钟,并且除非我重新启动容器,否则修改不会出现在浏览器上。我已经阅读了很多关于如何使用 docker 设置 HMR 的指南和帖子,但到目前为止,它们都没有奏效。
这是我的 Dockerfile.dev
FROM node:lts
RUN mkdir -p /home/app
WORKDIR /home/app
COPY package.json yarn.lock /home/app/
RUN yarn
COPY . .
CMD ["yarn", "dev"]
还有 docker-compose.yaml:
version: '3'
services:
database:
image: 'mariadb:latest'
restart: always
environment:
MYSQL_ROOT_PASSWORD: password
api:
depends_on:
- database
build:
dockerfile: Dockerfile.dev
context: ./api
volumes:
- /home/app/node_modules
- ./api:/home/app
ports:
- 4000:3000
client:
depends_on:
- api
build:
dockerfile: Dockerfile.dev
context: ./client
volumes:
- /home/app/node_modules
- ./client:/home/app
ports:
- 3000:3000
【问题讨论】:
标签: docker docker-compose next.js webpack-hmr