agentleFS
ai-enhanced-engineerai-enhanced-engineer/aiee-skills/skills/laravel-sail-docker/SKILL.md

laravel-sail-docker

Skill4 starsChanged 5 months agoMITView on GitHub

Laravel Docker development and production environment. Sail for local dev (MySQL, Redis, Mailhog), production PHP-FPM images, multi-stage builds, container permissions. Use for local dev setup, production Dockerfiles, or deployment containerization.

  • Reads credentials

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 0 are distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Use delegated consistency mode for 3-5x faster file access:

    line 58
  2. Very specific:

    Use a mysql:8 service container for Laravel CI when any migration calls dropForeign() inside up().

    line 98

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Laravel Sail Docker Development

Laravel Sail provides Docker-powered local development environment with MySQL, Redis, Mailhog, and other services pre-configured.

When to Use

  • Setting up Laravel local development environment
  • Configuring Docker services (MySQL, Redis, etc.)
  • Troubleshooting Docker/Sail issues
  • Adding custom services to docker-compose
  • Optimizing volume performance (macOS)
  • Running Artisan commands in containers

Quick Start

# Create alias for convenience
alias sail='./vendor/bin/sail'

# Start environment
sail up -d

Common Commands

CommandPurposeExample
sail upStart all servicessail up -d (detached)
sail downStop all servicessail down
sail artisanRun Artisan commandssail artisan migrate
sail composerRun Composersail composer install
sail npmRun NPMsail npm run dev
sail testRun PHPUnit testssail test --filter UserTest
sail shellAccess app containersail shell
sail mysqlAccess MySQL CLIsail mysql
sail redisAccess Redis CLIsail redis

Docker Services

Default services:

  • Laravel app (http://localhost)
  • MySQL 8.0 (localhost:3306)
  • Redis (localhost:6379)
  • Mailhog UI (http://localhost:8025)
  • Meilisearch (http://localhost:7700)
  • Selenium (browser testing)

Volume Performance (macOS)

Use delegated consistency mode for 3-5x faster file access:

volumes:
    - '.:/var/www/html:delegated'

Production PHP-FPM Image

For production (not Sail), use php:8.2-fpm with Laravel extensions (opcache, zip, mbstring, bcmath, pcntl + database driver: pdo_pgsql or pdo_mysql). Key production settings:

  • OPcache: validate_timestamps=0 (eliminates stat calls — safe in immutable containers)
  • FPM pool: pm = dynamic, pm.max_requests = 500 (guards memory leaks), size max_children as container_memory_mb / avg_process_mb
  • Non-root: Remapping www-data to UID 1000 avoids permission mismatches on Linux hosts (default UID 33 on Debian, 82 on Alpine)

Multi-Stage Builds

Three-stage separation: (1) composer:2 for composer install --no-dev, (2) node:20-alpine for npm ci && npm run build, (3) php:8.2-fpm-alpine (lightweight base) copies only /vendor and public/build. Copy lock files before source code for layer caching (saves 30-90s per CI build).

Container Storage Permissions

Build-time COPY --chown=www-data:www-data works when storage is not volume-mounted. For named volumes or bind mounts, use an entrypoint script: chown -R www-data:www-data storage bootstrap/cache && exec "$@". The exec "$@" is required for correct PID 1 signal handling.

Anti-Patterns

Anti-PatternPattern
Port conflict (3306, 6379)Stop local MySQL/Redis or change port in .env (service already running on host)
Permission deniedsail shell then chown -R sail:sail /var/www/html (file ownership mismatch)
Slow performance (macOS)Use :delegated consistency mode (default volume sync mode)
Container not startingCheck docker ps -a and stop conflicting containers (port already in use)
Database connection refusedWait for health checks or use depends_on with condition: service_healthy (service not ready)
Running PHP-FPM as root in productionUse USER www-data after chown — exposes host if container escapes
validate_timestamps=1 in productionSet to 0 — code never changes in immutable containers
chmod -R 777 for storage permissionsUse 775 — 777 grants write to all users including attackers
chown in build layer on volume-mounted pathWork discarded at runtime — use entrypoint script instead
Composer/Node in production imageUse multi-stage builds — build tools expand attack surface

GitHub Actions: MySQL Service Container

Use a mysql:8 service container for Laravel CI when any migration calls dropForeign() inside up(). SQLite :memory: does not support dropping foreign keys and throws BadMethodCallException on migrate:fresh. The full health-check incantation:

services:
  mysql:
    image: mysql:8
    env:
      MYSQL_ROOT_PASSWORD: root
      MYSQL_DATABASE: testing
    options: >-
      --health-cmd="mysqladmin ping -h localhost -u root -proot"
      --health-interval=10s
      --health-retries=10
    ports:
      - 3306:3306

setup-php step must include extensions: pdo_mysql explicitly. Inject DB_CONNECTION: mysql, DB_HOST: 127.0.0.1 via job-level env:. Check for dropForeign in migration up() methods before defaulting to SQLite.

See reference.md for installation steps, health checks, environment variables, Xdebug configuration. See examples.md for custom services (PostgreSQL), Dockerfile patterns, troubleshooting workflows, example project configuration.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

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.