Token导航 LogoToken导航TokenDH.com
开发执行命令github未标认证来源可访问许可证需确认审计通过

dockerfile-generatordockerfile 生成器

Agent Skill

用于辅助云资源、部署、容器、基础设施和运维自动化任务。它适合让 Agent 检查配置、整理部署步骤、分析资源状态、生成排障思路或辅助云服务接入。使用时需要明确目标环境、账号权限、区域和资源组,区分本地测试与生产操作;涉及删除资源、重启服务、修改网络或权限配置时,应先确认影响范围。

总安装

188

周安装

8

GitHub Stars

公开资料未说明

下载量

66
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:dockerfile-generator(dockerfile 生成器)
来源仓库:https://github.com/karchtho/my-claude-marketplace
仓库路径:skills/dockerfile-generator
安装命令:
npx skills add https://github.com/karchtho/my-claude-marketplace --skill dockerfile-generator
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/karchtho/my-claude-marketplace --skill dockerfile-generator

简介

用于自动生成标准化的 Dockerfile 配置。

  • 适合快速搭建应用镜像、优化构建流程或统一团队规范。
  • 需根据应用语言、依赖和环境提供准确的技术栈信息。
  • 生成的配置应适配多阶段构建和安全最佳实践。
  • 使用前建议核对基础镜像版本和依赖兼容性。dockerfile-generator 属于开发类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Dockerfile Generator

Generate optimized, production-ready Dockerfiles for common application stacks with built-in best practices.

When to Use

  • Creating new application containers
  • Optimizing existing Dockerfiles
  • Multi-stage builds for size reduction
  • Language-specific containerization
  • Security hardening
  • Build performance optimization
  • Implementing health checks

Universal Principles

Base Image Selection

Use CaseBase ImageNotes
Node.jsnode:20-alpineSlim, fast, widely compatible
Pythonpython:3.11-slimMinimal footprint
Gogolang:1.21-alpineCompiler included for builds
Rustrust:latestLarge but efficient
Javaeclipse-temurin:21-jre-alpineJRE only for production
Generaldebian:bookworm-slimFull tooling when needed

Rule of thumb: Use Alpine for production (smaller, faster), Debian/Ubuntu for development (more tools).

Node.js/TypeScript

Multi-Stage Production Build

# Build stage
FROM node:20-alpine AS builder
WORKDIR /app

# Copy dependency files
COPY package*.json ./

# Install dependencies (including dev)
RUN npm ci

# Copy source
COPY . .

# Build/compile
RUN npm run build

# Lint and test (optional)
RUN npm run lint && npm run test:unit

# Production stage
FROM node:20-alpine
WORKDIR /app

# Create non-root user
RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001

# Copy built artifacts from builder
COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
COPY --chown=nodejs:nodejs package*.json ./

# Switch to non-root user
USER nodejs

# Health check
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
  CMD node -e "require('http').get('http://localhost:3000/health', (r) => {if(r.statusCode!==200) throw new Error(r.statusCode)})"

EXPOSE 3000

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

Development Container

FROM node:20-alpine

WORKDIR /app

RUN npm install -g nodemon

COPY package*.json ./
RUN npm ci

COPY . .

EXPOSE 3000

CMD ["nodemon", "src/server.js"]

Python

Multi-Stage Build

# Build stage
FROM python:3.11-slim AS builder
WORKDIR /app

# Install build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
    build-essential && rm -rf /var/lib/apt/lists/*

# Create virtual environment
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

# Copy requirements
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Production stage
FROM python:3.11-slim
WORKDIR /app

# Create non-root user
RUN useradd -m -u 1001 appuser

# Copy virtual environment
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

# Copy application
COPY --chown=appuser:appuser . .

USER appuser

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
  CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8000/health')"

EXPOSE 8000

CMD ["gunicorn", "-w", "4", "-b", "0.0.0.0:8000", "app:app"]

Go

Minimal Binary Container

# Build stage
FROM golang:1.21-alpine AS builder
WORKDIR /app

# Install build tools
RUN apk add --no-cache git

# Copy source
COPY go.mod go.sum ./
RUN go mod download

COPY . .

# Build static binary
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build \
    -ldflags="-w -s" \
    -o myapp .

# Production stage (minimal distroless)
FROM gcr.io/distroless/base-debian11

WORKDIR /app

# Copy binary
COPY --from=builder /app/myapp .

EXPOSE 8080

ENTRYPOINT ["./myapp"]

Standard Go Container

# Build stage
FROM golang:1.21-alpine AS builder
WORKDIR /app

COPY go.mod go.sum ./
RUN go mod download

COPY . .

RUN CGO_ENABLED=0 GOOS=linux go build -o app .

# Runtime stage
FROM alpine:3.18
RUN apk add --no-cache ca-certificates
WORKDIR /root/

COPY --from=builder /app/app .

EXPOSE 8080

CMD ["./app"]

Rust

Release Build

# Build stage
FROM rust:latest AS builder
WORKDIR /app

COPY . .

RUN cargo build --release

# Runtime stage
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates && rm -rf /var/lib/apt/lists/*

COPY --from=builder /app/target/release/myapp /usr/local/bin/

EXPOSE 8080

CMD ["myapp"]

Java

Spring Boot Application

# Build stage
FROM maven:3.9-eclipse-temurin-21 AS builder
WORKDIR /app

COPY pom.xml .
RUN mvn dependency:go-offline

COPY src ./src
RUN mvn package -DskipTests

# Runtime stage
FROM eclipse-temurin:21-jre-alpine
WORKDIR /app

# Create non-root user
RUN addgroup -g 1001 -S appgroup && adduser -S appuser -u 1001 -G appgroup

# Copy JAR
COPY --from=builder /app/target/app.jar .

USER appuser

HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
  CMD wget --quiet --tries=1 --spider http://localhost:8080/actuator/health || exit 1

EXPOSE 8080

CMD ["java", "-jar", "app.jar"]

Key Optimization Techniques

Layer Caching

# BAD - changes frequently, invalidates cache
COPY . .
RUN npm ci
RUN npm run build

# GOOD - stable layers cached longer
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build

.dockerignore

node_modules/
npm-debug.log
.git/
.gitignore
.env*
.vscode/
dist/
build/
coverage/
.DS_Store

Combine RUN Commands

# BAD - 3 layers
RUN apt-get update
RUN apt-get install -y curl
RUN rm -rf /var/lib/apt/lists/*

# GOOD - 1 layer
RUN apt-get update && apt-get install -y curl && rm -rf /var/lib/apt/lists/*

Security Patterns

Non-Root User

RUN groupadd -r appgroup && useradd -r -g appgroup appuser
USER appuser

Read-Only Filesystem

docker run --read-only -v /tmp:/tmp myapp:latest

Drop Capabilities

# Dockerfile
USER nobody:nobody

# Or runtime
docker run --cap-drop=ALL --cap-add=NET_BIND_SERVICE myapp:latest

Health Checks

HTTP Endpoint

HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
  CMD curl -f http://localhost:3000/health || exit 1

Custom Script

COPY healthcheck.sh .
RUN chmod +x healthcheck.sh
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
  CMD ./healthcheck.sh

Database Connectivity

HEALTHCHECK --interval=30s --timeout=5s --retries=3 \
  CMD pg_isready -h localhost -U postgres || exit 1

Build Arguments

ARG NODE_ENV=production
ARG BUILD_DATE
ARG VCS_REF
ARG VERSION

LABEL org.opencontainers.image.created=$BUILD_DATE \
      org.opencontainers.image.revision=$VCS_REF \
      org.opencontainers.image.version=$VERSION

ENV NODE_ENV=$NODE_ENV

# Build
RUN npm run build:$NODE_ENV

Build Command

DOCKER_BUILDKIT=1 docker build \
  --build-arg NODE_ENV=production \
  --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
  --build-arg VCS_REF=$(git rev-parse --short HEAD) \
  --build-arg VERSION=1.0.0 \
  -t myapp:1.0.0 \
  .

Common Issues & Solutions

Issue: Large Image Size

Solution: Use multi-stage builds, Alpine base images, and .dockerignore

# Before: 1.2GB
FROM ubuntu:22.04
RUN apt-get update && apt-get install -y python3 pip ...
COPY . .

# After: 120MB
FROM python:3.11-slim AS builder
RUN pip install --user ...
FROM python:3.11-slim
COPY --from=builder ...

Issue: Layer Cache Invalidation

Solution: Order commands by change frequency

# Stable → Frequently changing
COPY package.json .
RUN npm ci
COPY . .
RUN npm run build

Issue: Slow Builds

Solution: Enable BuildKit and use layer caching

# Enable BuildKit
export DOCKER_BUILDKIT=1

# Build with progress output
docker buildx build --progress=plain -t myapp .

Testing Dockerfile

# Build image
docker build -t myapp:test .

# Run with shell for inspection
docker run -it myapp:test /bin/sh

# Verify file contents
docker run myapp:test ls -la /app

# Check environment
docker run myapp:test env

References

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

36.73%
按下载量换算24

Claude

29.43%
按下载量换算19

Cursor

20.42%
按下载量换算13

Gemini CLI

10.23%
按下载量换算7

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

执行命令

安装流程涉及命令执行,可能通过 npx skills add https://github.com/karchtho/my-claude-marketplace --skill dockerfile-generator 联网下载 Skill 或依赖。用户安装前应确认命令来源、仓库内容和执行环境。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills