create-docker-compose-production

为 PHP 项目生成 Docker Compose 的生产环境配置。侧重于构建加固的堆栈,包含资源限制、重启策略和监控功能。

仓库最近推送
GitHub Stars
109
Forks
26
Issues / PRs
1

安装方式

先用 Prompt 核对来源与依赖。也可下载安装包。

用 AI 助手安装

复制提示词,让助手先核对固定版本和依赖。

查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "create-docker-compose-production":https://skillpi.com/zh/skills/deepskill-fce67d880f7f4a1963351f6622b7088c955f20692d7ddd31f9ea58bdbc95dbfe。安装前核对上游来源和版本:https://github.com/dykyi-roman/awesome-claude-code。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。

来源与配置

github.com

配置方式待核实

请查看原始来源中的适用工具、依赖和权限要求。

安装实测待补充

为 PHP 项目生成 Docker Compose 的生产环境配置。侧重于构建加固的堆栈,包含资源限制、重启策略和监控功能。

0 下载

介绍来源: third_party · dykyi-roman · 0.0.1 参考来源

SkillPi 解读

能完成的任务
翻译待完成,请参阅来源文档。
实测状态
未测试

文件浏览

在原站浏览文件 ↗

原始 SKILL.md

打开原文 ↗
Frontmatter
name: create-docker-compose-production
description: Generates Docker Compose production configurations for PHP projects. Creates hardened stacks with resource limits, restart policies, and monitoring.

Docker Compose Production Generator

Generates hardened Docker Compose production configurations with resource limits, restart policies, network segmentation, and logging.

Generated Files

docker-compose.prod.yml   # Production stack configuration

Generation Instructions

  1. Analyze: Identify services, determine resource needs, plan network segmentation, define persistence
  2. Harden: Resource limits, restart policies, read-only root, network segmentation, log rotation, health checks
  3. Configure: Service dependencies with health conditions, graceful shutdown, persistent volumes

Docker Compose Production Stack

# docker-compose.prod.yml
services:
  php:
    image: ${REGISTRY:-registry.example.com}/app:${APP_VERSION:-latest}
    restart: unless-stopped
    read_only: true
    tmpfs:
      - /tmp:size=64M
      - /var/run:size=1M
    environment:
      APP_ENV: prod
      APP_DEBUG: "0"
      DATABASE_URL: "postgresql://${DB_USER}:${DB_PASSWORD}@database:5432/${DB_NAME}?serverVersion=17"
      REDIS_URL: "redis://redis:6379"
      RABBITMQ_URL: "amqp://${RABBITMQ_USER}:${RABBITMQ_PASS}@rabbitmq:5672"
    depends_on:
      database: { condition: service_healthy }
      redis: { condition: service_healthy }
    healthcheck:
      test: ["CMD-SHELL", "SCRIPT_NAME=/ping SCRIPT_FILENAME=/ping REQUEST_METHOD=GET cgi-fcgi -bind -connect 127.0.0.1:9000 || exit 1"]
      interval: 30s
      timeout: 5s
      start_period: 15s
      retries: 3
    deploy:
      resources:
        limits: { cpus: "2.0", memory: 512M }
        reservations: { cpus: "0.5", memory: 256M }
      replicas: 2
    logging: { driver: json-file, options: { max-size: "10m", max-file: "5" } }
    stop_grace_period: 30s
    networks: [backend]

  nginx:
    image: nginx:1.27-alpine
    restart: unless-stopped
    read_only: true
    tmpfs:
      - /tmp:size=32M
      - /var/cache/nginx:size=64M
      - /var/run:size=1M
    ports:
      - "${HTTP_PORT:-80}:80"
      - "${HTTPS_PORT:-443}:443"
    volumes:
      - ./docker/nginx/production.conf:/etc/nginx/conf.d/default.conf:ro
      - ssl-certs:/etc/nginx/ssl:ro
      - static-files:/app/public:ro
    depends_on:
      php: { condition: service_healthy }
    deploy:
      resources:
        limits: { cpus: "1.0", memory: 256M }
        reservations: { cpus: "0.25", memory: 64M }
    logging: { driver: json-file, options: { max-size: "10m", max-file: "10" } }
    stop_grace_period: 15s
    networks: [frontend, backend]

  database:
    image: postgres:17-alpine
    restart: unless-stopped
    environment:
      POSTGRES_DB: ${DB_NAME}
      POSTGRES_USER: ${DB_USER}
      POSTGRES_PASSWORD: ${DB_PASSWORD}
      POSTGRES_INITDB_ARGS: "--data-checksums"
    volumes:
      - db-data:/var/lib/postgresql/data
      - db-backups:/backups
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${DB_USER} -d ${DB_NAME}"]
      interval: 10s
      timeout: 5s
      start_period: 30s
      retries: 5
    deploy:
      resources:
        limits: { cpus: "2.0", memory: 1G }
        reservations: { cpus: "0.5", memory: 512M }
    command: >
      postgres
      -c shared_buffers=256MB
      -c effective_cache_size=768MB
      -c max_connections=100
      -c log_min_duration_statement=1000
    shm_size: 256M
    stop_grace_period: 60s
    networks: [backend]

  redis:
    image: redis:7-alpine
    restart: unless-stopped
    read_only: true
    tmpfs: [/tmp:size=16M]
    command: redis-server --appendonly yes --maxmemory 256mb --maxmemory-policy allkeys-lru --loglevel warning
    volumes:
      - redis-data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5
    deploy:
      resources:
        limits: { cpus: "1.0", memory: 320M }
        reservations: { cpus: "0.25", memory: 128M }
    stop_grace_period: 15s
    networks: [backend]

  rabbitmq:
    image: rabbitmq:3.13-alpine
    restart: unless-stopped
    environment:
      RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER}
      RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASS}
      RABBITMQ_VM_MEMORY_HIGH_WATERMARK: 0.4
    volumes:
      - rabbitmq-data:/var/lib/rabbitmq
    healthcheck:
      test: ["CMD", "rabbitmq-diagnostics", "check_running"]
      interval: 30s
      timeout: 10s
      start_period: 30s
      retries: 5
    deploy:
      resources:
        limits: { cpus: "1.0", memory: 512M }
        reservations: { cpus: "0.25", memory: 256M }
    stop_grace_period: 30s
    networks: [backend]

  worker:
    image: ${REGISTRY:-registry.example.com}/app:${APP_VERSION:-latest}
    restart: unless-stopped
    read_only: true
    tmpfs: [/tmp:size=64M]
    environment:
      APP_ENV: prod
      APP_DEBUG: "0"
      DATABASE_URL: "postgresql://${DB_USER}:${DB_PASSWORD}@database:5432/${DB_NAME}?serverVersion=17"
      REDIS_URL: "redis://redis:6379"
      RABBITMQ_URL: "amqp://${RABBITMQ_USER}:${RABBITMQ_PASS}@rabbitmq:5672"
    command: ["php", "bin/console", "messenger:consume", "async", "--time-limit=3600", "--memory-limit=256M"]
    depends_on:
      database: { condition: service_healthy }
      rabbitmq: { condition: service_healthy }
    deploy:
      resources:
        limits: { cpus: "1.0", memory: 384M }
      replicas: 2
    logging: { driver: json-file, options: { max-size: "10m", max-file: "5" } }
    stop_grace_period: 60s
    networks: [backend]

volumes:
  db-data:
  db-backups:
  redis-data:
  rabbitmq-data:
  ssl-certs:
  static-files:

networks:
  frontend:
    driver: bridge
    name: app-frontend
  backend:
    driver: bridge
    internal: true
    name: app-backend

Network Segmentation

Internet → [frontend] → nginx:80/443 → [backend (internal)] → php, database, redis, rabbitmq, worker
  • frontend: Only Nginx exposed to internet
  • backend: Internal network; database, Redis, RabbitMQ not accessible from outside

Production Deployment Commands

# Deploy with specific version
APP_VERSION=v1.2.3 docker compose -f docker-compose.prod.yml up -d

# Rolling update (zero-downtime)
APP_VERSION=v1.2.4 docker compose -f docker-compose.prod.yml up -d --no-deps php worker

# Scale workers
docker compose -f docker-compose.prod.yml up -d --scale worker=4

# Database backup
docker compose -f docker-compose.prod.yml exec database \
    pg_dump -U app -d app --format=custom > backup.dump

Security Checklist

  • Read-only root filesystem on stateless services
  • tmpfs for temporary file needs
  • Network segmentation (frontend/backend)
  • No management ports exposed (RabbitMQ management disabled)
  • Resource limits prevent runaway processes
  • Restart policies for fault tolerance
  • Log rotation prevents disk exhaustion
  • Graceful shutdown timeouts configured
  • Database data checksums enabled

Usage

Provide:

  • Services required (database, cache, queue)
  • Database type (PostgreSQL/MySQL)
  • Resource constraints per service
  • SSL certificate strategy

The generator will:

  1. Create docker-compose.prod.yml with hardened services
  2. Configure network segmentation
  3. Set resource limits and restart policies
  4. Include health checks, logging, and backup config

当前收录版本

0.0.1

核对来源版本 ↗

质量评测

满分100 · 来自 SkillPi LAB 实验室的评测报告。

场景价值85/100

亮点

  • 为 PHP 项目生成生产级 Docker Compose 配置,解决实际部署痛点
  • 包含资源限制、重启策略、网络隔离等关键生产特性
  • 具有广泛受众的实用能力
触发精准95/100

亮点

  • 触发词精准完整,覆盖多种变体
  • 边界清晰,不易误触或漏触
结构规范95/100

待提升项

  • 缺少 When to Use 章节 原报告严重程度:轻微

    文档中缺少明确的 When to Use 使用场景说明章节

    改进建议:建议添加 When to Use 章节,明确说明何时使用此 Skill

  • 缺少端到端示例 原报告严重程度:轻微

    文档中缺少完整的端到端使用示例

    改进建议:建议添加一个完整的使用示例,展示从输入到输出的完整流程

亮点

  • 文档结构清晰,包含生成文件说明、生成指令、完整配置示例
  • frontmatter 完整,单文件未超过 500 行
  • 包含网络分段说明、部署命令、安全检查清单和使用说明
执行可靠90/100

亮点

  • 提供了完整的 docker-compose.prod.yml 配置
  • 包含健康检查、资源限制、重启策略、日志配置等可靠性机制
  • 部署命令明确,覆盖了主要异常场景
证据可验 (前四项均值)91/100

取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。

正文静态检测

100 / 100 · skillpi-20261123-no-r3-v1

正文未命中当前规则。

分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。

权限与使用前检查

根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。

未从主文档识别到上述常见操作,不能据此判断无需权限或没有风险。

本站展示提示不会授予权限。涉及文件改动、密钥、外部发送或费用时,仍由你使用的工具按需确认。

安全评级与访问范围

safe · 静态证据核验,不代表运行安全保证。

使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。