<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Andrés V</title>
    <description>The latest articles on DEV Community by Andrés V (@viavi_dev).</description>
    <link>https://dev.to/viavi_dev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4004434%2Fdf1dd5c0-64dc-463b-b87d-d843bd64b308.jpg</url>
      <title>DEV Community: Andrés V</title>
      <link>https://dev.to/viavi_dev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/viavi_dev"/>
    <language>en</language>
    <item>
      <title>Production-Ready CodeIgniter 4 + Docker Stack with CI/CD in Less than 10 Minutes</title>
      <dc:creator>Andrés V</dc:creator>
      <pubDate>Fri, 26 Jun 2026 19:10:55 +0000</pubDate>
      <link>https://dev.to/viavi_dev/production-ready-codeigniter-4-docker-stack-with-cicd-in-less-than-10-minutes-221j</link>
      <guid>https://dev.to/viavi_dev/production-ready-codeigniter-4-docker-stack-with-cicd-in-less-than-10-minutes-221j</guid>
      <description>&lt;h2&gt;
  
  
  The Problem Every PHP Developer Knows
&lt;/h2&gt;

&lt;p&gt;You 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.&lt;/p&gt;

&lt;p&gt;That setup time is dead time. It does not ship features. It does not impress clients.&lt;/p&gt;

&lt;p&gt;And you do it again on the next project.&lt;/p&gt;

&lt;p&gt;This 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.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Stack
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Component&lt;/th&gt;
&lt;th&gt;Version&lt;/th&gt;
&lt;th&gt;Role&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;PHP-FPM&lt;/td&gt;
&lt;td&gt;8.2&lt;/td&gt;
&lt;td&gt;FastCGI runtime&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CodeIgniter&lt;/td&gt;
&lt;td&gt;4.7&lt;/td&gt;
&lt;td&gt;MVC framework + Shield auth&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Nginx&lt;/td&gt;
&lt;td&gt;1.28-alpine&lt;/td&gt;
&lt;td&gt;Reverse proxy, static files&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MySQL&lt;/td&gt;
&lt;td&gt;8.4&lt;/td&gt;
&lt;td&gt;Primary database&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Redis&lt;/td&gt;
&lt;td&gt;7-alpine&lt;/td&gt;
&lt;td&gt;Cache, sessions, queue backend&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Supervisor&lt;/td&gt;
&lt;td&gt;system&lt;/td&gt;
&lt;td&gt;PID-1 process manager in prod&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PHPStan&lt;/td&gt;
&lt;td&gt;level 6&lt;/td&gt;
&lt;td&gt;Static analysis, zero errors&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rector&lt;/td&gt;
&lt;td&gt;1.x&lt;/td&gt;
&lt;td&gt;Automated PHP 8.2 refactoring&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PHPUnit&lt;/td&gt;
&lt;td&gt;10.5&lt;/td&gt;
&lt;td&gt;Full test suite, pcov driver&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Two Dockerfiles: &lt;code&gt;Dockerfile.dev&lt;/code&gt; for local development with pcov and git support, &lt;code&gt;Dockerfile&lt;/code&gt; for production with Supervisor as PID-1 and FastCGI healthcheck.&lt;/p&gt;




&lt;h2&gt;
  
  
  Up and Running in Under 10 Minutes
&lt;/h2&gt;

&lt;p&gt;Unzip the files into your folder project:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Build images, start containers, run migrations and seeders, verify health&lt;/span&gt;
make setup
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;make setup&lt;/code&gt; command does all of this in sequence: builds both images, starts all&lt;br&gt;
containers, waits for MySQL and Redis to be ready, runs migrations, seeds the database, and hits the healthcheck endpoint to confirm everything is alive.&lt;/p&gt;

&lt;p&gt;Verify the stack is healthy:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl http://localhost:8080/health
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expected response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"status"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ok"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"database"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ok"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"redis"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"ok"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"timestamp"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"2026-06-26T15:00:00+00:00"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you see that JSON, the full stack is running: PHP-FPM, Nginx, MySQL, Redis, migrations applied, seeders executed.&lt;/p&gt;




&lt;h2&gt;
  
  
  Three Decisions That Are Not Obvious
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Supervisor as PID-1, not php-fpm directly
&lt;/h3&gt;

&lt;p&gt;Running php-fpm as PID-1 means zombie processes accumulate in long-running containers.&lt;/p&gt;

&lt;p&gt;Supervisor handles signal forwarding correctly, reaps child processes, and restarts php-fpm if it crashes, without restarting the container.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Queue worker as a dedicated container
&lt;/h3&gt;

&lt;p&gt;The 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.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. pcov only in the dev image
&lt;/h3&gt;

&lt;p&gt;pcov is a coverage driver. It has no place in a production image. The dev Dockerfile copies &lt;code&gt;docker/php/pcov.ini&lt;/code&gt; into the image. The production Dockerfile does not.&lt;/p&gt;

&lt;p&gt;This keeps the production image clean and avoids loading an extension that does nothing in that context.&lt;/p&gt;




&lt;h2&gt;
  
  
  The CI/CD Pipeline
&lt;/h2&gt;

&lt;p&gt;Three quality gates run on every push and pull request:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;jobs&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;tests&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# PHPUnit full suite with pcov, coverage &amp;gt;= 20% enforced&lt;/span&gt;
  &lt;span class="na"&gt;stan&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# PHPStan level 6, zero errors required&lt;/span&gt;
  &lt;span class="na"&gt;rector&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Rector dry-run, must exit clean&lt;/span&gt;
  &lt;span class="na"&gt;ci-gate&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="c1"&gt;# Blocks docker publish if any gate above failed&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No tag gets pushed without all three gates passing. The &lt;code&gt;release.yml&lt;/code&gt; workflow validates the CHANGELOG entry for the version before creating the GitHub release.&lt;/p&gt;




&lt;h2&gt;
  
  
  Quality Gate Results (v1.1.4)
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;PHPStan level 6: 0 errors&lt;/li&gt;
&lt;li&gt;Rector dry-run: clean&lt;/li&gt;
&lt;li&gt;PHPUnit: 424 tests, 710 assertions&lt;/li&gt;
&lt;li&gt;Lines coverage: 30.39% (gate minimum: 20%)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Three Configurations
&lt;/h2&gt;

&lt;p&gt;The kit ships in three configurations depending on the infrastructure level you need:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Starter&lt;/strong&gt; — Docker dev + prod, CI4 4.7, PHP 8.2, Nginx, MySQL 8.4, Redis 7, optimized Composer autoload, basic healthcheck endpoint.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Professional&lt;/strong&gt; — 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.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ultimate&lt;/strong&gt; — 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.&lt;/p&gt;

&lt;p&gt;If you want to use the stack without building each piece from scratch, it is available here: &lt;a href="https://viavi.mx/es/productos/ci4-docker-premium-starter-kit" rel="noopener noreferrer"&gt;CI4 Docker Premium Starter Kit&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What stack are you running for local CI4 development?
&lt;/h2&gt;

&lt;p&gt;Are you using Docker Compose, Laravel Valet, XAMPP, or something else entirely?&lt;br&gt;
Drop it in the comments.&lt;/p&gt;

</description>
      <category>php</category>
      <category>codeigniter</category>
      <category>docker</category>
      <category>devops</category>
    </item>
  </channel>
</rss>
