Communitygithub.com

Docker Optimizer

Dockerfile의 모범 사례, 보안 문제, 이미지 크기 최적화(멀티스테이지 빌드 및 레이어 캐싱 포함)를 검토합니다. Docker, 컨테이너 또는 배포 작업 시 유용합니다.

Docker Optimizer란 무엇인가요?

이 스킬은 Dockerfile을 분석하고 최적화하여 컨테이너 이미지의 성능, 보안 및 효율성을 향상시킵니다. 사용자가 Docker 관련 작업을 하거나 컨테이너 이미지 크기를 줄이려 할 때 활성화됩니다. 주요 기능으로는 구체적인 베이스 이미지 버전 사용, 레이어 수 최소화, 명령어 변경 빈도에 따른 순서 조정, .dockerignore 활용 등 Docker 모범 사례를 자동으로 점검합니다. 또한 멀티스테이지 빌드를 통해 최종 이미지 크기를 크게 줄이고, 루트 사용자 실행 방지, 시크릿 하드코딩 금지와 같은 보안 이슈를 찾아냅니다. Alpine 기반 이미지 사용, 불필요한 파일 제거, 구체적인 COPY 명령 등을 권장하며, BuildKit을 활용한 효율적인 빌드 명령과 함께 최적화된 Dockerfile과 .dockerignore 파일을 생성합니다. 사용자는 최종적으로 제공되는 체크리스트를 통해 Dockerfile이 업계 표준을 충족하는지 확인할 수 있습니다.

지원 대상~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/ComeOnOliver/skillshub/tree/HEAD/skills/aiskillstore/marketplace/crazydubya/docker-optimizer

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

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

문서

Docker Optimizer은(는) 무엇을 하나요?

Dockerfile의 성능, 보안 및 모범 사례를 분석하고 최적화합니다.

사용 시기

  • 사용자가 Docker 또는 컨테이너로 작업 중일 때
  • Dockerfile 최적화가 필요할 때
  • 컨테이너 이미지가 너무 클 때
  • 사용자가 "Docker", "컨테이너", "이미지 크기", "배포"를 언급할 때

지침

1. Dockerfile 찾기

다음 파일을 검색하세요: Dockerfile, Dockerfile.*, *.dockerfile

2. 모범 사례 확인

구체적인 베이스 이미지 버전 사용:

# 나쁜 예
FROM node:latest

# 좋은 예
FROM node:18-alpine

레이어 최소화:

# 나쁜 예
RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y git

# 좋은 예
RUN apt-get update && \
    apt-get install -y curl git && \
    rm -rf /var/lib/apt/lists/*

명령어를 변경 빈도 순으로 정렬:

# 의존성은 코드보다 변경 빈도가 낮음
COPY package*.json ./
RUN npm install
COPY . .

.dockerignore 사용:

node_modules
.git
.env
*.md

3. 멀티스테이지 빌드

최종 이미지 크기 줄이기:

# 빌드 스테이지
FROM node:18 AS build
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
RUN npm run build

# 프로덕션 스테이지
FROM node:18-alpine
WORKDIR /app
COPY --from=build /app/dist ./dist
COPY --from=build /app/node_modules ./node_modules
CMD ["node", "dist/index.js"]

4. 보안 이슈

루트로 실행하지 않기:

RUN addgroup -S appgroup && adduser -S appuser -G appgroup
USER appuser

이미지에 시크릿 포함 금지:

# 나쁜 예: 하드코딩된 시크릿
ENV API_KEY=secret123

# 좋은 예: 빌드 인수 또는 런타임 환경 변수 사용
ARG BUILD_ENV
ENV NODE_ENV=${BUILD_ENV}

취약점 스캔:

docker scan image:tag
trivy image image:tag

5. 크기 최적화

Alpine 이미지 사용:

  • node:18-alpine vs node:18 (900MB → 170MB)
  • python:3.11-alpine vs python:3.11 (900MB → 50MB)

불필요한 파일 제거:

RUN npm install --production && \
    npm cache clean --force

구체적인 COPY 사용:

# 나쁜 예: 모든 것을 복사
COPY . .

# 좋은 예: 필요한 것만 복사
COPY package*.json ./
COPY src ./src

6. 캐싱 전략

레이어 캐싱 최적화:

# 먼저 의존성 설치 (package.json이 변경되지 않으면 캐시 사용)
COPY package*.json ./
RUN npm install

# 소스 복사 (변경 빈도가 높음)
COPY . .
RUN npm run build

7. 헬스 체크

HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
  CMD node healthcheck.js

8. 최적화된 Dockerfile 생성

다음이 적용된 개선된 버전 제공:

  • 멀티스테이지 빌드
  • 적절한 베이스 이미지
  • 보안 개선 사항
  • 레이어 최적화
  • 빌드 캐싱
  • .dockerignore 파일

9. 빌드 명령어

효율적인 빌드:

# BuildKit 사용
DOCKER_BUILDKIT=1 docker build -t app:latest .

# 레지스트리에서 캐시를 사용하여 빌드
docker build --cache-from myregistry/app:latest -t app:latest .

10. Dockerfile 체크리스트

  • 구체적인 베이스 이미지 태그 (latest 사용 금지)
  • 해당하는 경우 멀티스테이지 빌드
  • 루트가 아닌 사용자
  • 최소 레이어 (RUN 명령어 통합)
  • .dockerignore 파일 존재
  • 이미지에 시크릿 없음
  • 캐싱을 위한 적절한 레이어 순서
  • Alpine 또는 slim 변형 사용
  • 동일 RUN 레이어에서 정리 작업 수행
  • HEALTHCHECK 정의됨

보안 모범 사례

  • 이미지 정기적으로 스캔
  • 공식 베이스 이미지 사용
  • 베이스 이미지 업데이트 유지
  • 공격 표면 최소화 (패키지 수 줄이기)
  • 루트가 아닌 사용자로 실행
  • 가능한 경우 읽기 전용 파일시스템 사용

지원 파일

  • templates/Dockerfile.optimized: 최적화된 멀티스테이지 Dockerfile 예제
  • templates/.dockerignore: 일반적인 .dockerignore 패턴

Individual skills in this repo

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

ComeOnOliver/skillshub

Create stunning, animation-rich HTML presentations from scratch or by converting PowerPoint files. Use when the user wants to build a presentation, convert a PPT/PPTX to web, or create slides for a talk/pitch. Helps non-designers discover their aesthetic through visual exploration rather than abstract choices.

ComeOnOliver/skillshub

Next.js 16+ 和 Turbopack — 增量打包、文件系统缓存、开发速度,以及何时使用 Turbopack 与 webpack。

ComeOnOliver/skillshub

SwiftUI architecture patterns, state management with @Observable, view composition, navigation, performance optimization, and modern iOS/macOS UI best practices.

ComeOnOliver/skillshub

See, Understand, Act on video and audio. See- ingest from local files, URLs, RTSP/live feeds, or live record desktop; return realtime context and playable stream links. Understand- extract frames, build visual/semantic/temporal indexes, and search moments with timestamps and auto-clips. Act- transcode and normalize (codec, fps, resolution, aspect ratio), perform timeline edits (subtitles, text/image overlays, branding, audio overlays, dubbing, translation), generate media assets (image, audio, video), and create real time alerts for events from live streams or desktop capture.

ComeOnOliver/skillshub

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

ComeOnOliver/skillshub

Next.js 15 애플리케이션을 위한 프론트엔드 개발 가이드라인. React 19, TypeScript, Shadcn/ui, Tailwind CSS를 사용한 모던 패턴. Server Components, Client Components, App Router, 파일 구조, Shadcn/ui 컴포넌트, 성능 최적화, TypeScript 모범 사례 포함. 컴포넌트, 페이지, 기능 생성, 데이터 페칭, 스타일링, 라우팅, 프론트엔드 코드 작업 시 사용.

ComeOnOliver/skillshub

Provides Tamagui patterns for config v4, compiler optimization, styled context, and cross-platform styling. Must use when working with Tamagui projects (tamagui.config.ts, @tamagui imports).

ComeOnOliver/skillshub

Create distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.

ComeOnOliver/skillshub

Create high-converting, visually distinctive landing pages. Use when building marketing pages, product launches, SaaS homepages, or any single-page conversion-focused website. Guides section-by-section composition with anti-AI-slop principles.

ComeOnOliver/skillshub

Auto-loaded context for Portfolio Buddy 2 development. Use for ANY task involving: React 19 development, TypeScript, portfolio analysis features, metrics calculations, trading strategy comparison, or working with the Portfolio Buddy 2 codebase. Contains tech stack, known issues, and architectural constraints.

ComeOnOliver/skillshub

Next.js development tooling via MCP. Inspect routes, components, build info, and debug Next.js apps. Use when working on Next.js applications, debugging routing, or inspecting app structure. NOT for general React or non-Next.js projects.

ComeOnOliver/skillshub

Implement UI using Shadcn MCP (atoms/theme) and 21st.dev MCP (complex sections). Use when adding buttons, layouts, or generating landing pages.

ComeOnOliver/skillshub

A conceptual skill for building an API client in Next.js that handles JWT tokens

ComeOnOliver/skillshub

Best practices and patterns for Next.js App Router, Server Actions, and Routing in this project.

ComeOnOliver/skillshub

The Design System, Theme, and UX rules for the Physical AI Hub.

ComeOnOliver/skillshub

Comprehensive frontend development skill for building modern, performant web applications using ReactJS, NextJS, TypeScript, Tailwind CSS. Includes component scaffolding, performance optimization, bundle analysis, and UI best practices. Use when developing frontend features, optimizing performance, implementing UI/UX designs, managing state, or reviewing frontend code.

ComeOnOliver/skillshub

This document captures learnings from fixing keyboard navigation issues when floating components (Select, DropdownMenu, Popover) have CSS open/close animations.

ComeOnOliver/skillshub

Build Next.js 16 applications with correct patterns and distinctive design. Use when creating pages, layouts, dynamic routes, upgrading from Next.js 15, or implementing proxy.ts. Covers breaking changes (async params/searchParams, Turbopack, cacheComponents) and frontend aesthetics. NOT when building non-React or backend-only applications.

ComeOnOliver/skillshub

Comprehensive Framer Motion animation library for React. Covers motion components, variants, gestures, page transitions, and scroll animations. Use when adding animations to React/Next.js applications.

ComeOnOliver/skillshub

Build interfaces that resonate, not just render. This skill enforces bold, intentional

관련 스킬