docker-patterns
Skill10 starsChanged 3 months agoMITView on GitHub
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.
- Reads credentials
We split this skill into the rules it gives an agent
5 rules. 0 are common, 0 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 11 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 67
Run as the non-root app user.
- Very specific: line 162
Use --mount=type=secret for build-time-only secrets (private Composer repo token) so they never persist in the final image.
- Very specific: line 186
Use -alpine bases; install with --no-cache (apk) / clean apt lists in the same RUN.
- Very specific: line 188
Add --mount=type=cache (BuildKit) for the Composer/npm cache to speed rebuilds without bloating the image.
- Very specific: line 196
No volumes for MySQL/Redis — data lost on down.
“Common” is measured: kept by at least 6 in 10 of the 11 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
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.
# syntax=docker/dockerfile:1
# --- Stage: composer deps (cached unless composer.* change) ---
FROM composer:2 AS vendor
WORKDIR /app
COPY composer.json composer.lock ./
RUN composer install --no-dev --no-scripts --prefer-dist \
--optimize-autoloader --no-interaction
# --- Stage: node/vite asset build ---
FROM node:22-alpine AS assets
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY vite.config.js ./
COPY resources ./resources
RUN npm run build # emits public/build via laravel-vite-plugin
# --- Stage: runtime (php-fpm, non-root, opcache) ---
FROM php:8.3-fpm-alpine AS runtime
RUN apk add --no-cache fcgi \
&& docker-php-ext-install pdo_mysql opcache bcmath pcntl \
&& addgroup -g 1000 -S app && adduser -S app -u 1000 -G app
COPY docker/php/opcache.ini /usr/local/etc/php/conf.d/opcache.ini
WORKDIR /var/www/html
COPY --chown=app:app . .
COPY --from=vendor --chown=app:app /app/vendor ./vendor
COPY --from=assets --chown=app:app /app/public/build ./public/build
USER app
HEALTHCHECK --interval=30s --timeout=3s --start-period=10s \
CMD php-fpm-healthcheck || exit 1
EXPOSE 9000
CMD ["php-fpm"]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)
opcache.enable=1
opcache.memory_consumption=256
opcache.max_accelerated_files=20000
opcache.validate_timestamps=0
opcache.preload=/var/www/html/preload.php
opcache.preload_user=appdocker-compose (local dev)
services:
app: # PHP-FPM
build: { context: ., target: runtime }
volumes:
- .:/var/www/html # bind mount for hot reload
- /var/www/html/vendor # protect image vendor from host
env_file: [.env]
depends_on:
mysql: { condition: service_healthy }
redis: { condition: service_started }
nginx:
image: nginx:1.27-alpine
ports: ["8080:80"]
volumes:
- .:/var/www/html
- ./docker/nginx/default.conf:/etc/nginx/conf.d/default.conf:ro
depends_on: [app]
mysql:
image: mysql:8.4
environment:
MYSQL_DATABASE: app
MYSQL_USER: app
MYSQL_PASSWORD: ${DB_PASSWORD} # from host/.env, never inline
MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD}
ports: ["127.0.0.1:3306:3306"] # host-only; omit entirely in prod
volumes: [mysqldata:/var/lib/mysql]
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
interval: 5s
timeout: 3s
retries: 10
redis:
image: redis:7-alpine
command: ["redis-server", "--maxmemory-policy", "allkeys-lru"]
volumes: [redisdata:/data]
healthcheck:
test: ["CMD", "redis-cli", "ping"]
interval: 5s
timeout: 3s
retries: 5
queue: # worker — same image, different command
build: { context: ., target: runtime }
command: ["php", "artisan", "queue:work", "redis", "--tries=3", "--max-time=3600"]
env_file: [.env]
restart: unless-stopped
depends_on:
redis: { condition: service_started }
mysql: { condition: service_healthy }
scheduler: # one container running the scheduler loop
build: { context: ., target: runtime }
command: ["php", "artisan", "schedule:work"]
env_file: [.env]
restart: unless-stopped
depends_on:
mysql: { condition: service_healthy }
volumes:
mysqldata:
redisdata:- 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
vendor
node_modules
.env
.env.*
.git
storage/logs/*
storage/framework/cache/*
public/build
docker-compose*.yml
*.md
testsExcluding 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.
Other versions40 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 40
- loulanyue/awesome-claude-notes★ 272same name
- langchain-ai/skills-benchmarks★ 116same name
- tranhieutt/software_development_department★ 71same name
- Fmarzochi/EGC★ 61same name
- sabahattink/antigravity-fullstack-hq★ 30same name
- skateddu/claude-code-python-setup★ 28same name
- woxiangyangzhimao/skills★ 14same name
- edjchapman/claude-code-config★ 8same name
- gongyijie85/dsh-ecc★ 8same name
- VoVuongThanhDat/agentflow★ 8same name
30 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
Used alongsideProjects with it also use content-hash-cache-pattern, ralphinho-rfc-pipeline and 9 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
royaluniondesign-sysSkillcontent-hash-cache-pattern
Cache expensive file processing results using SHA-256 content hashes — path-independent, auto-invalidating, with service layer separation.
Also in 12 projects that use this
junimnjwSkillralphinho-rfc-pipeline
RFC-driven multi-agent DAG execution pattern with quality gates, merge queues, and work unit orchestration.
Also in 8 projects that use this
royaluniondesign-sysSkillconfigure-ecc
Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.
Also in 7 projects that use this
Yog-SothoSkillpytorch-patterns
PyTorch deep learning patterns and best practices for building robust, efficient, and reproducible training pipelines, model architectures, and data loading. Always activate when the user is writing PyTorch models or training scripts, reviewing deep learning code, debugging training loops or data pipelines, optimizing GPU memory or training speed, setting up reproducible experiments, implementing transfer learning or fine-tuning, or asks anything about nn.Module, DataLoader, autograd, AMP, or torch.compile.
Also in 10 projects that use this
junimnjwSkillcontinuous-agent-loop
Patterns for continuous autonomous agent loops with quality gates, evals, and recovery controls.
Also in 11 projects that use this
loulanyueSkillnuxt4-patterns
Nuxt 4 app patterns for hydration safety, performance, route rules, lazy loading, and SSR-safe data fetching with useFetch and useAsyncData.
Also in 6 projects that use this
- +3 more from royaluniondesign-sys
- +2 more from junimnjw
In this repository62 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- analyze-problemSkill
- api-reviewSkill
- article-writingSkill
- assignment-compliance-checkSkill
- automation-audit-opsSkill
- autonomous-loopsSkill
- benchmark-optimization-loopSkill
- benchmarkSkill
- blueprintSkill
- class-refactoringSkill
- cleanup-local-branchesSkill
- codebase-simplification-auditSkill
- code-review-bugsnagSkill
- code-review-githubSkill
- code-review-jiraSkill
- code-reviewSkill
- composer-updateSkill
- create-issues-from-textSkill
- create-issueSkill
- create-missing-tests-in-prSkill
- create-testSkill
- design-systemSkill
- e2e-testingSkill
- frontend-a11ySkill
- frontend-design-directionSkill
- frontend-patternsSkill
- frontend-slidesSkill
- git-workflowSkill
- laravel-authorization-reviewSkill
- laravel-securitySkill
- laravel-telescopeSkill
- latency-critical-systemsSkill
- merge-github-prSkill
- mysql-patternsSkill
- mysql-problem-solverSkill
- penetration-testerSkill
- postgres-patternsSkill
- prepare-issue-contextSkill
- process-code-reviewSkill
- product-capabilitySkill
- production-auditSkill
- pr-staged-merge-planSkill
- pr-summarySkill
- record-project-memorySkill
- redis-patternsSkill
- refactor-entry-point-to-actionSkill
- refresh-claude-mdSkill
- resolve-issueSkill
- rewrite-tests-pestSkill
- security-bounty-hunterSkill
- security-reviewSkill
- security-threat-analysisSkill
- seoSkill
- skill-creatorSkill
- slack-messagingSkill
- smartest-project-additionSkill
- test-driven-developmentSkill
- tester-cookbookSkill
- test-like-humanSkill
- The first 60 shown.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
Reviews can't be read right now.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

