쿠버네티스/cka

Next.js 서버 Pod로 띄우기

몽자비루 2025. 2. 25. 23:59
  1. Next.js 애플리케이션 개발을 위한 설정 구성을 위해 사용됨
    1. create-next-app 설치하기

      • 포커싱된 경로의 my-app 에 생성된다.
    2. Next.js 프로젝트가 잘 작동하는지 확인하기
      • npm run dev 실행하기
      • localhost:3000 입력하기
    3. 이미지 생성하기
      • Dockerfile 파일 생성하기
         
      • FROM node:20-alpine WORKDIR /app RUN npm install RUN npm run build EXPOSE 3000 ENTRYPOINT [ "npm", "run", "start"]
      • Dockerignore 파일 생성하기
        node_modules
    4. 이미지 빌드하기
      • docker build -t next-server .
    5. asdf
      • 매니페스트 파일 생성
        apiVersion: v1
        kind: Pod
        metadata:
          name: next-pod
        spec:
          containers:
            - name: next-container
              image: next-server
              imagePullPolicy: IfNotPresent
              ports:
                - containerPort: 3000
         
      •  Pod 생성하기

      • 포트포워딩 후 접속하기