Agent Native

docker-build-deploy

This skill generates a complete Docker CI/CD pipeline for Node.js applications, creating an optimized Dockerfile with multi-stage builds and non-root user…

by wu529778790CommunityNot reviewed

Community author

Agents
Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode, claude.ai and API
License
MIT (permissive)
Pin
91d8122pinned Oct 9, 2026
Context cost
about 730 tokenswhen the skill loads
GitHub stars
3on wu529778790/shenzjd-skills
Scripts
None found

What it does

“Use when containerizing a Node.js app and setting up GitHub Actions CI/CD to build, push to GHCR, and deploy via SSH. Multi-stage build, non-root user, caching.”
The author's description, from SKILL.md

Generated summary from the skill's own text

This skill generates a complete Docker CI/CD pipeline for Node.js applications, creating an optimized Dockerfile with multi-stage builds and non-root user, plus a GitHub Actions workflow that automatically builds images, pushes to GHCR, and deploys to a remote server via SSH.

When to use it

  • Containerizing a Node.js app with automated deployment
  • Setting up CI/CD to build and push Docker images to GHCR
  • Deploying containerized applications to servers via SSH
  • Optimizing Dockerfiles with multi-stage builds and security best practices

When not to

  • Deploying to Kubernetes, AWS ECS/EKS, or managed container platforms
  • Using CI/CD systems other than GitHub Actions
  • Only writing a Dockerfile without deployment automation

Install

These commands install from the publisher's repository and need no account.

skills CLI

npx skills add wu529778790/shenzjd-skills --skill docker-build-deploy

Installs from the repository's default branch, which may have changed since the commit we checked.

GitHub CLI 2.90 or later

gh skill install wu529778790/shenzjd-skills docker-build-deploy@91d81223806690723b86b0cc06dc65a29568c1ad

Installs the commit we checked (91d8122).

Copy by hand

Download the folder at 91d8122 and put it in .claude/skills/docker-build-deploy for Claude Code and in .agents/skills/docker-build-deploy for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode.

Skill folder on GitHub at 91d8122

Copy for your agent

A prompt for any coding agent. It installs this skill from GitHub at the pinned commit, copies the files as they are, and runs nothing unless you ask.

Prompt

Install the agent skill "docker-build-deploy" by wu529778790.

Source, pinned to commit 91d81223806690723b86b0cc06dc65a29568c1ad:
https://github.com/wu529778790/shenzjd-skills/tree/91d81223806690723b86b0cc06dc65a29568c1ad/docker-build-deploy

1. Download that folder at exactly this commit. Do not use the default branch.
2. Copy every file unchanged, keeping the folder structure, into .claude/skills/docker-build-deploy/ for Claude Code and .agents/skills/docker-build-deploy/ for Codex, Cursor, Gemini CLI, GitHub Copilot and OpenCode. Create the folders if they do not exist.
3. Do not edit the files, and do not run any script in the folder unless I ask you to.
4. When you are done, list the files you copied and where you put them.

Listing and checks: https://www.agentnative.dev/skills/wu529778790/docker-build-deploy

SKILL.md at the pin

---
name: docker-build-deploy
description: Use when containerizing a Node.js app and setting up GitHub Actions CI/CD to build, push to GHCR, and deploy via SSH. Multi-stage build, non-root user, caching.
---

# Docker Build & Deploy

一键生成 Docker 构建 + 推送到 GHCR + 部署到服务器的 GitHub Actions 工作流。

## Overview

自动生成完整的 Docker CI/CD 工作流:构建镜像 → 推送到 GHCR → SSH 部署到服务器。包含优化的 Dockerfile(多阶段构建、非 root、健康检查)和 GitHub Actions 工作流模板。

## When to Use

- User wants to containerize a project and deploy it
- User needs GitHub Actions to automatically build Docker images
- User mentions Docker, GHCR, container deployment, or CI/CD
- User inputs `/docker-build-deploy`
- User wants to set up continuous deployment pipeline
- User wants to push images to a container registry
- User wants to automate deployment to a remote server via SSH
- User wants to optimize existing Dockerfile with multi-stage builds
- User wants to add health checks to container deployment

**When NOT to Use:**
- User only wants to write a Dockerfile
- User deploys with Kubernetes (different workflow - consider `kubectl` or Helm)
- User doesn't use GitHub Actions (consider GitLab CI, CircleCI, etc.)
- User wants to deploy to AWS ECS/EKS, Google Cloud Run, or Azure Container Instances (different workflows)

## Core Pattern

### Step 1: 收集信息

交互式询问:`port`(容器内端口,默认 3000)、`host_port`(对外暴露端口,默认同 port)、`env_file`(服务器 env 路径,可选)。

智能检测:有 `package.json` → Node.js(当前唯一支持的项目类型)。已有 Dockerfile 则跳过生成。

### Step 2: 生成 Dockerfile(如需要)

生成优化的 Node.js Dockerfile:多阶段构建、非 root 用户、健康检查。模板见 `templates/Dockerfile.nodejs`。

### Step 3: 生成 Workflow

从 `templates/docker-deploy.yml` 生成工作流,替换 `{{PORT}}`(容器端口)、`{{HOST_PORT}}`(对外端口)和 `{{ENV_FILE}}` 变量。

**build-and-push job:** 登录 GHCR → Buildx 构建 → 推送(tag: latest + sha)→ GHA 缓存

**deploy job:** SSH 连接 → 拉取镜像 → 停旧容器 → 启新容器(支持 env 文件)→ 清理旧镜像

### Step 4: 提示配置 Secrets

告知用户需在 GitHub Settings → Secrets 配置:`DEPLOY_HOST`、`DEPLOY_USER`、`DEPLOY_SSH_KEY`(服务器私钥)。

> 安全性:使用 SSH key 而非密码(密码登录有爆破风险,且明文存于 CI)。若服务器只支持密码,可改用 `password: ${{ secrets.DEPLOY_PASSWORD }}`,但不推荐。

## Quick Reference

```bash
/docker-build-deploy
/docker-build-deploy --port 8080
/docker-build-deploy --port 8080 --env-file /opt/app/.env
```

| 参数 | 说明 | 默认值 |
|------|------|--------|
| `--port` | 容器内应用端口 | 3000 |
| `--host-port` | 服务器对外暴露端口 | 同 `--port` |
| `--env-file` | 服务器 env 文件路径 | 空 |

## Common Mistakes

| 错误 | 正确做法 | 原因 |
|------|----------|------|
| 用 `latest` 单 tag | 同时打 `latest` + `${{ github.sha }}` | 方便回滚 |
| 不设置 `packages: write` 权限 | 声明 `permissions: packages: write` | GHCR 推送需要 |
| deploy 不检查容器是否存在 | 先 `docker stop` + `docker rm` | 避免端口冲突 |
| 不清理旧镜像 | 部署后 `docker image prune -f` | 磁盘空间 |
| Dockerfile 用 root 运行 | 添加 `USER node` 或非 root 用户 | 容器安全最佳实践 |
| Secrets 硬编码在 workflow 中 | 使用 `${{ secrets.XXX }}` 引用 | 密钥泄露风险 |
| 不设置 Docker BuildKit 缓存 | 配置 `cache-from` / `cache-to` using GitHub Actions cache | 每次全量构建太慢 |
| 不处理构建失败的回滚 | 部署后验证健康检查 | 失败部署可能上线错误版本 |
| 用密码 SSH 部署 | 使用 SSH key(`DEPLOY_SSH_KEY`) | 密码爆破风险高 |
| 平台声明与服务器架构不符 | 按服务器架构声明 `linux/amd64` 或 `linux/arm64`;多平台构建时写 `linux/amd64,linux/arm64` | 目标架构不匹配导致运行失败 |

From wu529778790/shenzjd-skills at 91d8122, shown as plain text under its license: MIT (permissive). The license text is in LICENSE.

View SKILL.md on GitHub at 91d8122

Files

4 files, 8.9 KB in total. Each file has a sha256 in the pin's manifest; the first 12 characters are shown.

Skill folder on GitHub at 91d8122
All Cloud and DevOps skills
  • vercel-functions

    Vercel Functions expert guidance for Node.js/Bun/Python/Rust serverless functions on Fluid Compute.

    by VercelOfficial publisher

    Claude Code, Codex, Cursor +3 · about 8.9K tokens · pinned 6 days ago

  • ci-cd

    This skill guides agents through setting up CI/CD pipelines for .NET applications using GitHub Actions or Azure DevOps.

    by codewithmukeshCommunity

    Claude Code, Codex, Cursor +4 · about 1.3K tokens · pinned 6 days ago

  • linear-release-setup

    Generates CI/CD configuration files for Linear Release, a tool that syncs Git commits and deployments with Linear release pipelines.

    by linearCommunity

    Claude Code, Codex, Cursor +4 · about 2.5K tokens · pinned 6 days ago

  • debug-openshell-cluster

    Diagnoses OpenShell gateway deployment problems across Docker, Podman, Kubernetes, and VM compute platforms.

    by NVIDIAOfficial publisher

    Claude Code, Codex, Cursor +4 · about 19.1K tokens · pinned 6 days ago

  • huggingface-spaces

    Create and deploy machine-learning applications on Hugging Face Spaces using Gradio, Docker, or Static SDKs.

    by Hugging FaceOfficial publisher

    Claude Code, Codex, Cursor +4 · about 4.3K tokens · pinned 6 days ago

  • upgrading-mwaa-environments

    Upgrades an MWAA environment to a newer Apache Airflow version by computing the optimal version-jump path, selecting a deployment approach (new environment…

    by Amazon (AWS)Official publisher

    Claude Code, Codex, Cursor +4 · about 7K tokens · pinned 6 days ago

The skills listed here are third-party software, collected from public GitHub repositories as a catalog of recent skills and provided as is. Agent Native does not write or control them and is not responsible for any harm, loss or damage caused by installing or using them. Labels and checks describe what we saw at one commit and are not a guarantee. Read a skill's files before you run it. Terms of use