{
  "$type": "site.standard.document",
  "bskyPostRef": {
    "cid": "bafyreic2qfz4aldjy3rj6bmng7z52423pwlxkpb3sbobovnpa762am6y6m",
    "uri": "at://did:plc:25rdn5elo5izoxrmtis34zuk/app.bsky.feed.post/3mp7ptn2kbxs2"
  },
  "coverImage": {
    "$type": "blob",
    "ref": {
      "$link": "bafkreibe575nrt2uhguk3uyju7ssimjvuybicpoexryxs2unbkzv3wuz3e"
    },
    "mimeType": "image/webp",
    "size": 73504
  },
  "path": "/viavi_dev/production-ready-codeigniter-4-docker-stack-with-cicd-in-less-than-10-minutes-221j",
  "publishedAt": "2026-06-26T19:10:55.000Z",
  "site": "https://dev.to",
  "tags": [
    "php",
    "codeigniter",
    "docker",
    "devops",
    "CI4 Docker Premium Starter Kit"
  ],
  "textContent": "##  The Problem Every PHP Developer Knows\n\nYou start a new CodeIgniter 4 project. Before writing a single line of business logic, you spend hours on setup: getting Docker to work, configuring Nginx, wiring PHP-FPM, setting up MySQL and Redis, making PHPUnit run inside the container, and then figuring out why your CI pipeline fails on the first push.\n\nThat setup time is dead time. It does not ship features. It does not impress clients.\n\nAnd you do it again on the next project.\n\nThis article walks through the complete stack I built to solve that, and how it gets you from zero to a running, tested, production-ready CI4 environment in under 10 minutes.\n\n##  The Stack\n\nComponent | Version | Role\n---|---|---\nPHP-FPM | 8.2 | FastCGI runtime\nCodeIgniter | 4.7 | MVC framework + Shield auth\nNginx | 1.28-alpine | Reverse proxy, static files\nMySQL | 8.4 | Primary database\nRedis | 7-alpine | Cache, sessions, queue backend\nSupervisor | system | PID-1 process manager in prod\nPHPStan | level 6 | Static analysis, zero errors\nRector | 1.x | Automated PHP 8.2 refactoring\nPHPUnit | 10.5 | Full test suite, pcov driver\n\nTwo Dockerfiles: `Dockerfile.dev` for local development with pcov and git support, `Dockerfile` for production with Supervisor as PID-1 and FastCGI healthcheck.\n\n##  Up and Running in Under 10 Minutes\n\nUnzip the files into your folder project:\n\n\n\n    # Build images, start containers, run migrations and seeders, verify health\n    make setup\n\n\nThe `make setup` command does all of this in sequence: builds both images, starts all\ncontainers, waits for MySQL and Redis to be ready, runs migrations, seeds the database, and hits the healthcheck endpoint to confirm everything is alive.\n\nVerify the stack is healthy:\n\n\n\n    curl http://localhost:8080/health\n\n\nExpected response:\n\n\n\n    {\n      \"status\": \"ok\",\n      \"database\": \"ok\",\n      \"redis\": \"ok\",\n      \"timestamp\": \"2026-06-26T15:00:00+00:00\"\n    }\n\n\nIf you see that JSON, the full stack is running: PHP-FPM, Nginx, MySQL, Redis, migrations applied, seeders executed.\n\n##  Three Decisions That Are Not Obvious\n\n###  1. Supervisor as PID-1, not php-fpm directly\n\nRunning php-fpm as PID-1 means zombie processes accumulate in long-running containers.\n\nSupervisor handles signal forwarding correctly, reaps child processes, and restarts php-fpm if it crashes, without restarting the container.\n\n###  2. Queue worker as a dedicated container\n\nThe queue worker runs as a separate container sharing the same image, not as a Supervisor program inside the web container. This means you can scale the worker independently, restart it without touching the web process, and read its logs in isolation.\n\n###  3. pcov only in the dev image\n\npcov is a coverage driver. It has no place in a production image. The dev Dockerfile copies `docker/php/pcov.ini` into the image. The production Dockerfile does not.\n\nThis keeps the production image clean and avoids loading an extension that does nothing in that context.\n\n##  The CI/CD Pipeline\n\nThree quality gates run on every push and pull request:\n\n\n\n    jobs:\n      tests:\n        # PHPUnit full suite with pcov, coverage >= 20% enforced\n      stan:\n        # PHPStan level 6, zero errors required\n      rector:\n        # Rector dry-run, must exit clean\n      ci-gate:\n        # Blocks docker publish if any gate above failed\n\n\nNo tag gets pushed without all three gates passing. The `release.yml` workflow validates the CHANGELOG entry for the version before creating the GitHub release.\n\n##  Quality Gate Results (v1.1.4)\n\n  * PHPStan level 6: 0 errors\n  * Rector dry-run: clean\n  * PHPUnit: 424 tests, 710 assertions\n  * Lines coverage: 30.39% (gate minimum: 20%)\n\n\n\n##  Three Configurations\n\nThe kit ships in three configurations depending on the infrastructure level you need:\n\n**Starter** — Docker dev + prod, CI4 4.7, PHP 8.2, Nginx, MySQL 8.4, Redis 7, optimized Composer autoload, basic healthcheck endpoint.\n\n**Professional** — Everything in Starter plus complete GitHub Actions CI/CD (ci/publish/release workflows), Sentry validated at runtime, Supervisor PID-1, FastCGI production-grade HEALTHCHECK, dedicated queue-worker container, full multi-tenancy layer, PHPStan level 6 + Rector.\n\n**Ultimate** — Everything in Professional plus deployment guides for Railway, Render, and VPS Ubuntu, backup and restore scripts with 7-day rotation, production deploy scripts with rollback hint.\n\nIf you want to use the stack without building each piece from scratch, it is available here: CI4 Docker Premium Starter Kit\n\n##  What stack are you running for local CI4 development?\n\nAre you using Docker Compose, Laravel Valet, XAMPP, or something else entirely?\nDrop it in the comments.",
  "title": "Production-Ready CodeIgniter 4 + Docker Stack with CI/CD in Less than 10 Minutes"
}