ec2-backend-deployer

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

EC2 Backend Deployer

EC2 后端部署专家

Expert in deploying backend applications to EC2 instances using CI/CD pipelines, Docker containers, and GitHub Actions.
擅长使用CI/CD流水线、Docker容器和GitHub Actions将后端应用部署到EC2实例。

When to Use This Skill

何时使用此技能

Use when you're:
  • Setting up CI/CD for backend deployment to EC2
  • Configuring Docker-based deployments
  • Implementing automated deployment pipelines
  • Deploying NestJS, Next.js, or Express backends
  • Setting up container registries and image management
  • Configuring secure EC2 access (Tailscale)
当你需要以下操作时使用:
  • 为后端部署到EC2设置CI/CD
  • 配置基于Docker的部署
  • 实现自动化部署流水线
  • 部署NestJS、Next.js或Express后端
  • 设置容器注册表和镜像管理
  • 配置安全的EC2访问(Tailscale)

Quick Workflow

快速工作流程

  1. Dockerfile: Multi-stage build (base → builder → production)
  2. Registry: GitHub Container Registry (ghcr.io) recommended
  3. CI/CD: GitHub Actions with Tailscale for secure SSH
  4. Deploy: Docker Compose on EC2 with health checks
  5. Verify: Health endpoint + deployment verification
  1. Dockerfile:多阶段构建(基础 → 构建 → 生产)
  2. 注册表:推荐使用GitHub Container Registry (ghcr.io)
  3. CI/CD:结合Tailscale实现安全SSH的GitHub Actions
  4. 部署:在EC2上使用Docker Compose并配置健康检查
  5. 验证:健康端点 + 部署验证

Key Components

核心组件

Docker

Docker

  • Multi-stage builds for smaller images
  • Non-root user for security
  • HEALTHCHECK for container orchestration
  • BuildKit secrets for sensitive data
  • 多阶段构建以生成更小的镜像
  • 使用非root用户提升安全性
  • HEALTHCHECK用于容器编排
  • BuildKit密钥处理敏感数据

GitHub Actions

GitHub Actions

  • docker/build-push-action
    for image building
  • tailscale/github-action
    for secure access
  • appleboy/ssh-action
    for deployment
  • 使用
    docker/build-push-action
    构建镜像
  • 使用
    tailscale/github-action
    实现安全访问
  • 使用
    appleboy/ssh-action
    执行部署

EC2

EC2

  • Docker Compose v2 required
  • Health check verification
  • Rollback procedures
  • 需要Docker Compose v2
  • 健康检查验证
  • 回滚流程

References

参考资料

  • Full guide: Dockerfile, CI/CD workflow, deployment, troubleshooting
  • 完整指南:Dockerfile、CI/CD工作流、部署、故障排查