Token导航 LogoToken导航TokenDH.com
运维和基础设施需要联网github未标认证来源可访问许可证需确认审计通过

docker-multi-stageDocker multi stage 部署

Agent Skill

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

总安装

470

周安装

20

GitHub Stars

1

下载量

165
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-docker --skill docker-multi-stage

简介

运用多阶段构建技术将镜像体积缩减 50%-90%,分离编译与运行环境。

  • 提供 Node.js/Python/Go/Rust/Java 等语言的专用优化模板,支持 Distroless 基础镜像。
  • 自动配置健康检查、资源限制与构建缓存策略,适配云原生部署要求。
  • 需指定目标语言与运行时版本,建议使用 Alpine 或 Distroless 减小基础镜像尺寸。
  • docker-multi-stage 属于运维和基础设施类 Skill,可作为该场景下的辅助能力补充。

SKILL.md

Docker Multi-Stage Builds Skill

Create optimized, minimal production images using multi-stage builds with language-specific patterns.

Purpose

Reduce image size by 50-90% by separating build dependencies from runtime, following 2024-2025 best practices.

Parameters

ParameterTypeRequiredDefaultDescription
languageenumYes-node/python/go/rust/java
targetstringNoruntimeBuild target stage
base_runtimestringNo-Custom runtime base image

Multi-Stage Patterns

Node.js (Alpine + Distroless)

# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build && npm prune --production

# Runtime stage (distroless = minimal attack surface)
FROM gcr.io/distroless/nodejs20-debian12 AS runtime
WORKDIR /app
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/node_modules ./node_modules
USER nonroot
CMD ["dist/index.js"]

Python (Slim + Virtual Environment)

# Build stage
FROM python:3.12-slim AS builder
WORKDIR /app
RUN python -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt

# Runtime stage
FROM python:3.12-slim AS runtime
WORKDIR /app
COPY --from=builder /opt/venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
COPY . .
USER nobody
CMD ["python", "main.py"]

Go (Scratch = Smallest Possible)

# Build stage
FROM golang:1.22-alpine AS builder
WORKDIR /app
COPY go.* ./
RUN go mod download
COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o /app/server

# Runtime stage (scratch = 0 base size)
FROM scratch AS runtime
COPY --from=builder /app/server /server
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
USER 65534
ENTRYPOINT ["/server"]

Rust (Musl for Static Linking)

# Build stage
FROM rust:1.75-alpine AS builder
RUN apk add --no-cache musl-dev
WORKDIR /app
COPY . .
RUN cargo build --release --target x86_64-unknown-linux-musl

# Runtime stage
FROM scratch AS runtime
COPY --from=builder /app/target/x86_64-unknown-linux-musl/release/app /app
USER 65534
ENTRYPOINT ["/app"]

Java (JRE Only Runtime)

# Build stage
FROM eclipse-temurin:21-jdk-alpine AS builder
WORKDIR /app
COPY . .
RUN ./gradlew build --no-daemon

# Runtime stage (JRE only, not JDK)
FROM eclipse-temurin:21-jre-alpine AS runtime
WORKDIR /app
COPY --from=builder /app/build/libs/*.jar app.jar
USER nobody
ENTRYPOINT ["java", "-jar", "app.jar"]

Size Comparison

LanguageBeforeAfterReduction
Node.js1.2GB150MB87%
Python900MB120MB87%
Go800MB10MB99%
Rust1.5GB5MB99.7%
Java600MB200MB67%

Error Handling

Common Errors

ErrorCauseSolution
COPY --from failedStage not foundCheck stage name
not found at runtimeMissing libsUse alpine, not scratch
permission deniedNon-root userCOPY --chown

Fallback Strategy

  1. Start with alpine instead of scratch/distroless
  2. Add required libraries incrementally
  3. Use ldd to identify missing dependencies

Troubleshooting

Debug Checklist

  • All required files copied to runtime stage?
  • SSL certificates included for HTTPS?
  • User/group exists in runtime image?
  • Build artifacts correctly located?

Debug Commands

# Check final image size
docker images myapp:latest

# Inspect layers
docker history myapp:latest --no-trunc

# Compare with baseline
dive myapp:latest

Usage

Skill("docker-multi-stage")

Assets

  • assets/Dockerfile.node-multistage - Node.js template
  • assets/Dockerfile.python-multistage - Python template

Related Skills

  • docker-optimization
  • dockerfile-basics

适合场景

01

用户想查找某类 Agent Skill 时

02

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

03

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

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

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

能力 4

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

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

平台分布

Codex

35.92%
按下载量换算59

Claude

30.96%
按下载量换算51

Cursor

20.87%
按下载量换算34

Gemini CLI

8.63%
按下载量换算14

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

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

来源信息

继续浏览同类 Skills