Community코딩 & 개발github.com

giuseppe-trisciuoglio/nextjs-deployment

Next.js 애플리케이션을 프로덕션에 배포하기 위한 포괄적인 패턴을 제공합니다. Docker 컨테이너 구성, GitHub Actions CI/CD 파이프라인 설정, 환경 변수 관리, 프리뷰 배포 구현, 또는 Next.js 애플리케이션 모니터링 및 로깅 설정 시 사용하세요. 독립형 출력, 다단계 Docker 빌드, 헬스 체크, OpenTelemetry 계측, 프로덕션 모범 사례를 다룹니다.

nextjs-deployment란 무엇인가요?

이 스킬은 Next.js 애플리케이션을 프로덕션 환경에 안정적이고 확장 가능한 방식으로 배포하기 위한 종합적인 가이드와 패턴을 제공합니다. 주로 Docker 컨테이너화, GitHub Actions 기반 CI/CD 파이프라인, 환경 변수 관리, 프리뷰 배포, 모니터링 및 로깅 설정에 중점을 둡니다. Next.js의 독립형(standalone) 출력 모드와 다단계(multi-stage) Docker 빌드를 활용하여 최적화된 이미지를 생성하며, 헬스 체크와 OpenTelemetry 계측을 통해 애플리케이션 상태와 성능을 모니터링할 수 있습니다. 이 스킬은 Claude Code, Cursor, Codex 등 다양한 AI 에이전트 플랫폼에서 사용 가능하며, 개발자가 프로덕션 환경에서 Next.js 애플리케이션을 안전하고 효율적으로 운영할 수 있도록 돕습니다. SKILL.md 문서는 상세한 설정 파일 예제, 환경 변수 구성 방법, 모니터링 도구 통합 방안, 보안 모범 사례 등을 포함하여 실무에서 바로 적용 가능한 정보를 제공합니다.

지원 대상~Claude Code~Codex CLI~Cursor
Part ofNext.js
npx skills add https://github.com/giuseppe-trisciuoglio/developer-kit/tree/main/skills/nextjs-deployment

Installed? Explore more 코딩 & 개발 skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

즐겨 사용하는 AI에게 물어보기

이 에이전트 스킬이 미리 로드된 새 채팅을 엽니다.

문서

nextjs-deployment은(는) 무엇을 하나요?

Next.js 애플리케이션을 프로덕션에 배포하기 위한 포괄적인 패턴을 제공합니다. Docker 컨테이너 구성, GitHub Actions CI/CD 파이프라인 설정, 환경 변수 관리, 프리뷰 배포 구현, 또는 Next.js 애플리케이션 모니터링 및 로깅 설정 시 사용하세요. 독립형 출력, 다단계 Docker 빌드, 헬스 체크, OpenTelemetry 계측, 프로덕션 모범 사례를 다룹니다.

주요 내용

  • 독립형 출력: Next.js의 output: 'standalone' 모드를 활용하여 최소한의 의존성으로 배포 가능한 애플리케이션 번들 생성
  • 다단계 Docker 빌드: 빌드 단계와 실행 단계를 분리하여 이미지 크기 최적화 및 보안 강화
  • 헬스 체크: 컨테이너 오케스트레이션 환경에서 애플리케이션 상태를 지속적으로 모니터링
  • OpenTelemetry 계측: 분산 추적 및 성능 메트릭 수집을 통한 애플리케이션 성능 모니터링
  • 환경 변수 관리: 런타임 환경 변수를 안전하게 주입하고 관리하는 방법
  • GitHub Actions CI/CD: 자동화된 테스트, 빌드, 배포 파이프라인 구성
  • 프리뷰 배포: PR 기반 프리뷰 환경을 통한 변경 사항 사전 검증

사용 예시

Dockerfile 예시

# 빌드 단계
FROM node:18-alpine AS builder
WORKDIR /app
COPY package.json package-lock.json* ./
RUN npm ci
COPY . .
RUN npm run build

# 실행 단계
FROM node:18-alpine AS runner
WORKDIR /app

ENV NODE_ENV production

COPY --from=builder /app/public ./public
COPY --from=builder /app/.next/standalone ./
COPY --from=builder /app/.next/static ./.next/static

EXPOSE 3000

ENV PORT 3000

CMD ["node", "server.js"]

docker-compose.yml 예시

version: '3.8'

services:
  nextjs:
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=production
      - DATABASE_URL=${DATABASE_URL}
      - OPENAI_API_KEY=${OPENAI_API_KEY}
    healthcheck:
      test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost:3000/api/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

GitHub Actions 워크플로우 예시

name: Deploy Next.js

on:
  push:
    branches: [ main ]
  pull_request:
    branches: [ main ]

jobs:
  build:
    runs-on: ubuntu-latest
    
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
          cache: 'npm'
      
      - name: Install dependencies
        run: npm ci
      
      - name: Run tests
        run: npm run test
      
      - name: Build application
        run: npm run build
        env:
          NEXT_PUBLIC_API_URL: ${{ secrets.NEXT_PUBLIC_API_URL }}
      
      - name: Build Docker image
        run: |
          docker build -t myapp:latest .
          docker tag myapp:latest myregistry.azurecr.io/myapp:${{ github.sha }}
      
      - name: Deploy to production
        run: |
          # 배포 스크립트 실행 (예: SSH, Kubernetes, 등)
          echo "Deploying to production..."

환경 변수 구성

변수명설명필수 여부
DATABASE_URL데이터베이스 연결 문자열예
OPENAI_API_KEYOpenAI API 키아니오 (해당 기능 사용 시)
NEXT_PUBLIC_API_URL클라이언트 측 API URL예
SENTRY_DSNSentry 오류 추적 DSN아니오
OTEL_EXPORTER_OTLP_ENDPOINTOpenTelemetry 수집기 엔드포인트아니오

모니터링 및 로깅

OpenTelemetry 설정

// instrumentation.ts
import { registerOTel } from '@vercel/otel';

export function register() {
  registerOTel({
    serviceName: 'nextjs-app',
  });
}

헬스 체크 엔드포인트

// app/api/health/route.ts
import { NextResponse } from 'next/server';

export async function GET() {
  return NextResponse.json({
    status: 'healthy',
    timestamp: new Date().toISOString(),
    uptime: process.uptime(),
  });
}

프로덕션 모범 사례

  1. 보안: 비밀 환경 변수는 Secrets Manager를 통해 관리
  2. 성능: CDN 캐싱, 이미지 최적화, 정적 페이지 사전 생성 활용
  3. 확장성: 수평 확장을 고려한 Stateless 애플리케이션 설계
  4. 모니터링: APM 도구와 연계하여 실시간 성능 모니터링
  5. 백업: 정기적인 데이터베이스 백업 및 복구 계획 수립

참고 자료

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

giuseppe-trisciuoglio/aws-lambda-java-integration

Provides AWS Lambda integration patterns for Java with cold start optimization. Use when deploying Java functions to AWS Lambda, choosing between Micronaut and Raw Java approaches, optimizing cold starts below 1 second, configuring API Gateway or ALB integration, or implementing serverless Java applications. Triggers include "create lambda java", "deploy java lambda", "micronaut lambda aws", "java lambda cold start", "aws lambda java performance", "java serverless framework".

giuseppe-trisciuoglio/aws-lambda-php-integration

Provides AWS Lambda integration patterns for PHP with Symfony using the Bref framework. Creates Lambda handler classes, configures runtime layers, sets up SQS/SNS event triggers, implements warm-up strategies, and optimizes cold starts. Use when deploying PHP/Symfony applications to AWS Lambda, configuring API Gateway integration, implementing serverless PHP applications, or optimizing Lambda performance with Bref. Triggers include "create lambda php", "deploy symfony lambda", "bref lambda aws", "php lambda cold start", "aws lambda php performance", "symfony serverless", "php serverless framework".

giuseppe-trisciuoglio/aws-lambda-python-integration

Provides AWS Lambda integration patterns for Python with cold start optimization. Use when deploying Python functions to AWS Lambda, choosing between AWS Chalice and raw Python approaches, optimizing cold starts, configuring API Gateway or ALB integration, or implementing serverless Python applications. Triggers include "create lambda python", "deploy python lambda", "chalice lambda aws", "python lambda cold start", "aws lambda python performance", "python serverless framework".

giuseppe-trisciuoglio/aws-lambda-typescript-integration

Provides AWS Lambda integration patterns for TypeScript with cold start optimization. Use when creating or deploying TypeScript Lambda functions, choosing between NestJS framework and raw TypeScript approaches, optimizing cold starts, configuring API Gateway or ALB integration, or implementing serverless TypeScript applications. Triggers include "create lambda typescript", "deploy typescript lambda", "nestjs lambda aws", "raw typescript lambda", "aws lambda typescript performance".

giuseppe-trisciuoglio/aws-rds-spring-boot-integration

Provides patterns to configure AWS RDS (Aurora, MySQL, PostgreSQL) with Spring Boot applications. Configures HikariCP connection pools, implements read/write splitting, sets up IAM database authentication, enables SSL connections, and integrates with AWS Secrets Manager. Use when setting up RDS connections in Spring Boot, configuring connection pooling, or managing database credentials securely.

giuseppe-trisciuoglio/aws-sdk-java-v2-bedrock

Provides Amazon Bedrock patterns using AWS SDK for Java 2.x. Invokes foundation models (Claude, Llama, Titan), generates text and images, creates embeddings for RAG, streams real-time responses, and configures Spring Boot integration. Use when asking about Bedrock integration, Java SDK for AI models, AWS generative AI, Claude/Llama invocation, embeddings for RAG, or Spring Boot AI setup.

giuseppe-trisciuoglio/aws-sdk-java-v2-core

Provides AWS SDK for Java 2.x client configuration, credential resolution, HTTP client tuning, timeout, retry, and testing patterns. Use when creating or hardening AWS service clients, wiring Spring Boot beans, debugging auth or region issues, or choosing sync vs async SDK usage.

giuseppe-trisciuoglio/aws-sdk-java-v2-dynamodb

Provides Amazon DynamoDB patterns using AWS SDK for Java 2.x. Use when creating, querying, scanning, or performing CRUD operations on DynamoDB tables, working with indexes, batch operations, transactions, or integrating with Spring Boot applications.

giuseppe-trisciuoglio/aws-sdk-java-v2-kms

Provides AWS Key Management Service (KMS) patterns using AWS SDK for Java 2.x. Use when creating/managing encryption keys, encrypting/decrypting data, generating data keys, digital signing, key rotation, or integrating encryption into Spring Boot applications.

giuseppe-trisciuoglio/aws-sdk-java-v2-lambda

Provides AWS Lambda patterns using AWS SDK for Java 2.x. Use when invoking Lambda functions, creating/updating functions, managing function configurations, working with Lambda layers, or integrating Lambda with Spring Boot applications.

giuseppe-trisciuoglio/aws-sdk-java-v2-messaging

Provides AWS messaging patterns using AWS SDK for Java 2.x for SQS queues and SNS topics. Handles sending/receiving messages, FIFO queues, DLQ, subscriptions, and pub/sub patterns. Use when implementing messaging with SQS or SNS.

giuseppe-trisciuoglio/aws-sdk-java-v2-rds

Provides AWS RDS (Relational Database Service) management patterns using AWS SDK for Java 2.x. Use when creating, modifying, monitoring, or managing Amazon RDS database instances, snapshots, parameter groups, and configurations.

giuseppe-trisciuoglio/aws-sdk-java-v2-s3

Provides Amazon S3 patterns and examples using AWS SDK for Java 2.x. Use when working with S3 buckets, uploading/downloading objects, multipart uploads, presigned URLs, S3 Transfer Manager, object operations, or S3-specific configurations.

giuseppe-trisciuoglio/aws-sdk-java-v2-secrets-manager

Provides AWS Secrets Manager patterns for AWS SDK for Java 2.x, including secret retrieval, caching, rotation-aware access, and Spring Boot integration. Use when storing or reading secrets in Java services, replacing hardcoded credentials, or wiring secret-backed configuration into applications.

giuseppe-trisciuoglio/better-auth

Provides Better Auth integration patterns for NestJS backend and Next.js frontend with Drizzle ORM and PostgreSQL. Use when setting up Better Auth with NestJS backend, integrating Next.js App Router frontend, configuring Drizzle ORM schema, implementing social login (GitHub, Google), adding plugins (2FA, Organization, SSO, Magic Link, Passkey), implementing email/password authentication with session management, or creating protected routes and middleware.

giuseppe-trisciuoglio/chunking-strategy

Provides chunking strategies for RAG systems. Generates chunk size recommendations (256-1024 tokens), overlap percentages (10-20%), and semantic boundary detection methods. Validates semantic coherence and evaluates retrieval precision/recall metrics. Use when building retrieval-augmented generation systems, vector databases, or processing large documents.

giuseppe-trisciuoglio/clean-architecture

Provides implementation patterns for Clean Architecture, Hexagonal Architecture (Ports & Adapters), and Domain-Driven Design in Java 21+ Spring Boot 3.5+ applications. Use when structuring layered architectures, separating domain logic from frameworks, implementing ports and adapters, creating entities/value objects/aggregates, or refactoring monolithic codebases for testability and maintainability.

giuseppe-trisciuoglio/docs-updater

Provides automated documentation updates by analyzing git changes between the current branch and the last release tag. Performs git diff analysis to identify modifications, then updates README.md, CHANGELOG.md following Keep a Changelog standard, and discovers documentation folders for contextual updates. Use when preparing a release, maintaining documentation sync, or before creating a pull request. Triggers on "update docs", "update changelog", "sync documentation", "update readme", "prepare release documentation".

giuseppe-trisciuoglio/drawio-logical-diagrams

Creates professional logical flow diagrams and logical system architecture diagrams using draw.io XML format (.drawio files). Use when creating: (1) logical flow diagrams showing data/process flow between system components, (2) logical architecture diagrams representing system structure without cloud provider specifics, (3) BPMN process diagrams, (4) UML diagrams (class, sequence, activity), (5) data flow diagrams (DFD), (6) decision flowcharts, or (7) system interaction diagrams. This skill focuses on generic/abstract representations, not AWS/Azure-specific architectures (use aws-drawio-architecture-diagrams for cloud diagrams).

giuseppe-trisciuoglio/drizzle-orm-patterns

Provides comprehensive Drizzle ORM patterns for schema definition, CRUD operations, relations, queries, transactions, and migrations. Proactively use for any Drizzle ORM development including defining database schemas, writing type-safe queries, implementing relations, managing transactions, and setting up migrations with Drizzle Kit. Supports PostgreSQL, MySQL, SQLite, MSSQL, and CockroachDB.

관련 스킬