Next.js with Docker-Compose
参考PR
https://github.com/teitei-tk/go-next.js-playground/pull/5
code:docker-compose.yml
version: "3.4"
services:
api:
build:
context: "./backend"
dockerfile: "Dockerfile.dev"
ports:
- 5000:5000
volumes:
- ./backend:/app/go
front:
build:
context: "./frontend"
dockerfile: "Dockerfile.dev"
ports:
- 3000:3000
volumes:
- ./frontend:/app/js
- /app/js/node_modules
- /app/js/.next
volumesに.nextを入れるのが重要
code:next.config.js
module.exports = {
webpackDevMiddleware: (config) => {
config.watchOptions = {
poll: 1000,
aggregateTimeout: 300,
};
return config;
},
};
Hot reloadを利用するためにwebpackDevMiddlewareの設定を追加する
https://github.com/vercel/next.js/blob/882288b532c70175c5421484a6dc5154420a2583/packages/next/build/webpack-config.ts#L1134
#next.js