nextjs 프로젝트 docker 빌드하는 방법
Post

nextjs 프로젝트 docker 빌드하는 방법

1. docker 설정 파일 추가

nextjs - With Docker 사이트에서 Dockerfile, .dockerignore 파일을 복사하여 nextjs 프로젝트 루트 위치에 추가해준다.

2. next.config.js에 설정 추가

1
2
3
4
5
6
7
8
9
10
/** @type {import('next').NextConfig} */
const nextConfig = {
    output: "standalone",
    reactStrictMode: false,
    compiler: {
        styledComponents: true
    }
}

module.exports = nextConfig

3. docker image 빌드

1
$ docker build -t nextjs-web:latest .

4. docker 실행

1
$ docker run -p 3000:3000 nextjs-web:latest