pekral/cursor-rules/docker-patterns
Claude Code and agent skill by pekral/cursor-rules
- community
Checking that the SKILL.md file is still in the repository.
Use when writing or reviewing Docker and docker-compose setups for a Laravel application — multi-stage PHP-FPM images, services (nginx, MySQL, Redis, queue worker, scheduler, Vite build), healthchecks, secrets, and image hardening.
Install
npx vskill@latest install pekral/cursor-rules/docker-patternsSKILL.md
The same SKILL.md was published earlier as pekral/cursor-rules/docker-patterns.
Docker Patterns
Constraints
- Apply
@rules/security/backend.md— never bake secrets into image layers, inject them at runtime; apply least privilege (non-root user, dropped capabilities, least-privileged DB user). - Apply
@rules/laravel/laravel.mdc— respect Laravel's directory layout, artisan commands, and config caching. - Pin every base image to a specific tag (never
:latest) for reproducible builds. - One process per container: PHP-FPM, queue worker, and scheduler are separate containers sharing the same image.
.envand secrets stay out of images and out of git.
Use when
- Writing or reviewing a
Dockerfile/docker-compose.ymlfor a Laravel app. - Setting up local dev (nginx + PHP-FPM + MySQL + Redis) or a build pipeline for a production image.
- Reviewing image size, layer caching, healthchecks, or secret handling.
Multi-Stage Dockerfile (PHP-FPM)
Separate Composer deps, the Vite/asset build, and the lean runtime so each layer caches independently and dev tooling never ships to production.
Key points:
--no-dev --optimize-autoloaderstrips dev packages and builds a classmap autoloader — smaller image, faster boot.--no-scriptsduring build avoids running artisan before the full app is copied; run cache-warming at deploy/entrypoint instead.- Production
opcache.ini:opcache.enable=1,opcache.validate_timestamps=0(no per-request stat — invalidate by redeploying), tunedmemory_consumption/max_accelerated_files. - Run as the non-root
appuser; the alpine base keeps the image small.
opcache.ini (production)
docker-compose (local dev)
- Services resolve each other by name on the Compose network:
DB_HOST=mysql,REDIS_HOST=redis. schedule:workruns the scheduler in-container (replaces a host crontab); the queue worker is its own restartable container so it scales independently of web.- For the Vite dev server (HMR) add
npm run devin a node service exposing port 5173, instead of the build stage.
Healthchecks
- PHP-FPM: ship
php-fpm-healthcheck(or a small FastCGI ping) — a plain TCP check won't catch a wedged pool. - Gate dependents with
depends_on: { condition: service_healthy }so the app doesn't boot before MySQL accepts connections. - Queue/scheduler containers:
restart: unless-stoppedso a transient crash self-recovers.
Secrets
- Inject at runtime via
env_file/environment/ orchestrator secrets — neverENV SECRET=...orCOPY .envinto a layer (layers are inspectable forever; see@rules/security/backend.md). - Use
--mount=type=secretfor build-time-only secrets (private Composer repo token) so they never persist in the final image. - Give the app a least-privileged MySQL user (no
GRANT ALL); reserve root for migrations/admin only.
.dockerignore
Excluding vendor/node_modules shrinks build context and forces deps to come from the cached composer/npm ci layers, not stale host copies.
Image Size & Layer Caching
- Copy
composer.json composer.lock(andpackage*.json) before the app source so dependency layers cache across code changes. - Use
-alpinebases; install with--no-cache(apk) / clean apt lists in the sameRUN. - Chain related
RUNcommands with&&to avoid extra layers; multi-stage keeps build tools out of the runtime image. - Add
--mount=type=cache(BuildKit) for the Composer/npm cache to speed rebuilds without bloating the image.
Anti-Patterns
:latesttags — non-reproducible builds. Pin versions.- Running as root — always create and
USERa non-root user. - Secrets in
docker-compose.ymlor image layers — use env/secrets. - One container running web + queue + scheduler — split them; one process per container.
- No volumes for MySQL/Redis — data lost on
down. Use named volumes. - Plain Compose as the production orchestrator for scale — fine for a single host; use Swarm/Kubernetes/ECS beyond that.
Done when
- Final image runs as non-root, ships
--no-devoptimized autoload + opcache, and contains no secrets or dev tooling. - Web, queue worker, and scheduler are separate containers sharing one image.
- MySQL and Redis have healthchecks and named volumes; dependents wait on
service_healthy. - Secrets come from env/secrets at runtime;
.dockerignoreexcludesvendor,node_modules,.env,.git. - Dependency layers are copied before source so the layer cache holds across code changes.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/docker-patterns/SKILL.md
Popularity
- Repository stars
- 9
- Repository forks
- 1
- 7-day trend score
- 12
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/pekral/cursor-rules/docker-patterns)