create-dockerfile-ci
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "create-dockerfile-ci" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-e738cd7a7998612c37e369e0f7b8fa77340e46fe87f158feb7eb7899d0f1b1f0. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
Generate an optimized Dockerfile for a PHP CI pipeline. Use multi-stage builds with separate stages for dependency installation, running tests, and producing the production image to minimize final image size.
Introduction source: third_party · dykyi-roman · 0.0.1 Reference
SkillPi interpretation
- Tasks
- Generates optimized Dockerfiles for PHP CI pipelines. Creates multi-stage builds with separate stages for dependencies, testing, and production with minimal image sizes.
- Testing
- Not tested
Browse files
Frontmatter
name: create-dockerfile-ci
description: Generates optimized Dockerfiles for PHP CI pipelines. Creates multi-stage builds with separate stages for dependencies, testing, and production with minimal image sizes.Dockerfile CI Generator
Generates optimized Dockerfiles for PHP projects with multi-stage builds.
Generated Files
Dockerfile # Production multi-stage build
Dockerfile.ci # CI-optimized build (optional)
.dockerignore # Exclude unnecessary files
Multi-Stage Production Dockerfile
# Dockerfile
# syntax=docker/dockerfile:1.6
#############################################
# Stage 1: Composer Dependencies
#############################################
FROM composer:2.7 AS composer
WORKDIR /app
# Copy only composer files for better caching
COPY composer.json composer.lock ./
# Install dependencies without dev packages
RUN composer install \
--no-dev \
--no-scripts \
--no-autoloader \
--prefer-dist \
--no-progress \
--ignore-platform-reqs
# Copy source code
COPY . .
# Generate optimized autoloader
RUN composer dump-autoload \
--no-dev \
--optimize \
--classmap-authoritative
#############################################
# Stage 2: PHP Extensions Builder
#############################################
FROM php:8.4-fpm-alpine AS php-builder
# Install build dependencies
RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
linux-headers \
libzip-dev \
icu-dev \
postgresql-dev \
libpng-dev \
libjpeg-turbo-dev \
freetype-dev \
libwebp-dev
# Install PHP extensions
RUN docker-php-ext-configure gd \
--with-freetype \
--with-jpeg \
--with-webp \
&& docker-php-ext-install -j$(nproc) \
pdo_pgsql \
pdo_mysql \
intl \
zip \
opcache \
gd \
pcntl \
bcmath
# Install Redis extension
RUN pecl install redis-6.0.2 \
&& docker-php-ext-enable redis
#############################################
# Stage 3: Production Image
#############################################
FROM php:8.4-fpm-alpine AS production
# Install runtime dependencies only
RUN apk add --no-cache \
libzip \
icu-libs \
libpq \
libpng \
libjpeg-turbo \
freetype \
libwebp
# Copy PHP extensions from builder
COPY --from=php-builder /usr/local/lib/php/extensions/ /usr/local/lib/php/extensions/
COPY --from=php-builder /usr/local/etc/php/conf.d/ /usr/local/etc/php/conf.d/
# Production PHP configuration
RUN mv "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"
# Opcache configuration for production
RUN echo "opcache.enable=1" >> /usr/local/etc/php/conf.d/opcache.ini \
&& echo "opcache.enable_cli=1" >> /usr/local/etc/php/conf.d/opcache.ini \
&& echo "opcache.memory_consumption=256" >> /usr/local/etc/php/conf.d/opcache.ini \
&& echo "opcache.interned_strings_buffer=16" >> /usr/local/etc/php/conf.d/opcache.ini \
&& echo "opcache.max_accelerated_files=20000" >> /usr/local/etc/php/conf.d/opcache.ini \
&& echo "opcache.validate_timestamps=0" >> /usr/local/etc/php/conf.d/opcache.ini \
&& echo "opcache.jit=1255" >> /usr/local/etc/php/conf.d/opcache.ini \
&& echo "opcache.jit_buffer_size=256M" >> /usr/local/etc/php/conf.d/opcache.ini
# PHP-FPM configuration
RUN echo "pm = dynamic" >> /usr/local/etc/php-fpm.d/zz-docker.conf \
&& echo "pm.max_children = 50" >> /usr/local/etc/php-fpm.d/zz-docker.conf \
&& echo "pm.start_servers = 5" >> /usr/local/etc/php-fpm.d/zz-docker.conf \
&& echo "pm.min_spare_servers = 5" >> /usr/local/etc/php-fpm.d/zz-docker.conf \
&& echo "pm.max_spare_servers = 35" >> /usr/local/etc/php-fpm.d/zz-docker.conf
# Create non-root user
RUN addgroup -g 1000 app \
&& adduser -u 1000 -G app -s /bin/sh -D app
WORKDIR /app
# Copy application from composer stage
COPY --from=composer --chown=app:app /app /app
# Set permissions
RUN chown -R app:app /app
USER app
# Health check (uses php only — curl/wget/fcgi are absent from the slim image)
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
CMD php -r 'exit(@fsockopen("127.0.0.1", 9000) ? 0 : 1);'
EXPOSE 9000
CMD ["php-fpm"]
CI-Optimized Dockerfile
# Dockerfile.ci
# Optimized for CI: fast builds, includes dev dependencies
FROM php:8.4-cli-alpine AS ci
# Install system dependencies
RUN apk add --no-cache \
git \
unzip \
libzip-dev \
icu-dev \
linux-headers \
$PHPIZE_DEPS
# Install PHP extensions
RUN docker-php-ext-install \
pdo_mysql \
intl \
zip \
pcntl \
bcmath
# Install Xdebug/PCOV for coverage
ARG COVERAGE_DRIVER=pcov
RUN if [ "$COVERAGE_DRIVER" = "pcov" ]; then \
pecl install pcov && docker-php-ext-enable pcov; \
elif [ "$COVERAGE_DRIVER" = "xdebug" ]; then \
pecl install xdebug && docker-php-ext-enable xdebug; \
fi
# Install Composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
# Configure PHP for CI
RUN echo "memory_limit=1G" >> /usr/local/etc/php/conf.d/ci.ini \
&& echo "max_execution_time=0" >> /usr/local/etc/php/conf.d/ci.ini
WORKDIR /app
# Copy composer files first for caching
COPY composer.json composer.lock ./
# Install all dependencies including dev
RUN composer install \
--prefer-dist \
--no-progress \
--no-interaction
# Copy source code
COPY . .
# Generate autoloader
RUN composer dump-autoload
# Default command
CMD ["vendor/bin/phpunit"]
Development Dockerfile
# Dockerfile.dev
# For local development with hot reload
FROM php:8.4-cli-alpine
# Install dependencies
RUN apk add --no-cache \
git \
unzip \
libzip-dev \
icu-dev \
linux-headers \
$PHPIZE_DEPS
# Install PHP extensions
RUN docker-php-ext-install \
pdo_mysql \
intl \
zip \
pcntl
# Install Xdebug for debugging
RUN pecl install xdebug \
&& docker-php-ext-enable xdebug
# Xdebug configuration
RUN echo "xdebug.mode=debug,coverage" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/xdebug.ini \
&& echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/xdebug.ini
# Install Composer
COPY --from=composer:2 /usr/bin/composer /usr/bin/composer
WORKDIR /app
# Don't copy files - mount volume instead
# COPY . .
CMD ["php", "-S", "0.0.0.0:8000", "-t", "public"]
Docker Compose for CI
# docker-compose.ci.yml
version: '3.8'
services:
app:
build:
context: .
dockerfile: Dockerfile.ci
args:
COVERAGE_DRIVER: pcov
volumes:
- ./coverage:/app/coverage
depends_on:
mysql:
condition: service_healthy
redis:
condition: service_healthy
environment:
DATABASE_URL: mysql://root:root@mysql:3306/test
REDIS_URL: redis://redis:6379
mysql:
image: mysql:8.0
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: test
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 5s
timeout: 5s
retries: 5
redis:
image: redis:7-alpine
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 5s
retries: 5
.dockerignore Template
# .dockerignore
# Git
.git
.gitignore
.gitattributes
# CI/CD
.github
.gitlab-ci.yml
Jenkinsfile
# IDE
.idea
.vscode
*.sublime-*
# Dependencies (will be installed in container)
vendor
# Tests (for production image)
tests
phpunit.xml*
.phpunit.result.cache
# Development files
docker-compose*.yml
Dockerfile*
.docker
# Documentation
docs
*.md
!README.md
# Cache and logs
var/cache
var/log
*.log
# Local configuration
.env.local
.env.*.local
*.local.php
# Static analysis
phpstan.neon
psalm.xml
.php-cs-fixer.php
deptrac.yaml
# Build artifacts
coverage
build
Build Arguments
PHP Version
ARG PHP_VERSION=8.4
FROM php:${PHP_VERSION}-fpm-alpine
Coverage Driver
ARG COVERAGE_DRIVER=none
RUN if [ "$COVERAGE_DRIVER" = "pcov" ]; then \
pecl install pcov && docker-php-ext-enable pcov; \
fi
Build Mode
ARG APP_ENV=prod
RUN if [ "$APP_ENV" = "prod" ]; then \
composer install --no-dev --optimize-autoloader; \
else \
composer install; \
fi
CI Build Commands
GitHub Actions
- name: Build CI image
run: |
docker build \
--file Dockerfile.ci \
--build-arg COVERAGE_DRIVER=pcov \
--tag app:ci \
.
- name: Run tests
run: |
docker run --rm \
-v ${{ github.workspace }}/coverage:/app/coverage \
app:ci \
vendor/bin/phpunit --coverage-clover=/app/coverage/coverage.xml
GitLab CI
build:
image: docker:24
services:
- docker:24-dind
script:
- docker build
--file Dockerfile.ci
--build-arg COVERAGE_DRIVER=pcov
--cache-from $CI_REGISTRY_IMAGE:ci
--tag $CI_REGISTRY_IMAGE:ci
.
- docker push $CI_REGISTRY_IMAGE:ci
Generation Instructions
-
Analyze project:
- Check PHP version in composer.json
- Identify required extensions
- Check for framework (Symfony, Laravel)
- Identify services (MySQL, Redis, etc.)
-
Generate Dockerfiles:
- Production: Multi-stage, optimized
- CI: Fast builds, dev dependencies
- Development: Hot reload, debugging
-
Optimize for caching:
- Copy composer files first
- Install dependencies before source
- Use multi-stage builds
-
Security:
- Non-root user
- Minimal base image
- No secrets in image
Usage
Provide:
- PHP version
- Required extensions
- Framework (optional)
- Services (MySQL, Redis, etc.)
- Target (production/ci/dev)
The generator will:
- Create appropriate Dockerfile(s)
- Generate .dockerignore
- Create docker-compose.ci.yml if needed
- Optimize for the target environment
Current listing version
0.0.1
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供多阶段构建的 Dockerfile 生成能力,有效解决 PHP CI 流水线中镜像体积最小化、依赖分离、测试与生产环境差异化等核心痛点
- 覆盖生产、CI、开发三种典型场景,具备高频刚需的实用价值
Highlights
- 触发描述精准覆盖'PHP CI 流水线'、'多阶段构建'、'最小镜像体积'等关键要素,边界清晰
Areas to improve
-
description 内容重复 Reported severity: Minor
顶层 frontmatter 和 skill_body 内部均包含 description,内容一致但存在冗余
Recommendation: 建议保留一处 description,避免重复
Highlights
- 文档结构清晰,分阶段展示生产、CI、开发环境的 Dockerfile,并提供 docker-compose 和 .dockerignore 模板
- 包含完整的构建指令和 GitHub Actions/GitLab CI 集成示例
Highlights
- 使用官方 PHP 和 Composer 镜像,参数配置合理,覆盖健康检查、非 root 用户等安全实践
- 多阶段构建有效分离构建时与运行时依赖,确保生产镜像最小化
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
These common operations were not identified in the main document. This does not mean no permissions or risks exist.
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.