Closed3

DockerでNextの環境構築

AuAgCuAuAgCu
ディレクトリ構成
.
├── front
│   └── Dockerfile
└── docker-compose.yml
Dockerfile
FROM node:19.5.0
ENV TZ=Asia/Tokyo
WORKDIR /app
docker-compose.yml
version: "3.8"
services:
  front:
    build:
      context: .
    tty: true
    ports:
      - "3000:3000"
    volumes:
      - ./react-sample:/src
    command: sh -c "npm install && npm run dev"
AuAgCuAuAgCu
$ docker-compose run --rm front bash
$ npx create-next-app src --typescript

いくつか選択肢が出てくるので適切なものを選択する。今回は以下を選択

  1. Ok to proceed? (y) → y
  2. Would you like to use ESLint with this project? … No / Yes → Yes
  3. Would you like to use src/ directory with this project? › No / Yes → Yes
  4. Would you like to use experimental app/ directory with this project? › No / Yes →No
  5. What import alias would you like configured? … @/* → 未入力でEnter
AuAgCuAuAgCu
$ exit
$ docker-compose up -d

localhost:3000にアクセスして以下のような画面が表示されれば成功

このスクラップは2023/02/07にクローズされました