Skip to main content

Zero-Downtime Deployment with Docker & GitHub Actions

By AJDM Jakiur Rahman 8 min read

Zero-downtime deployment means shipping a new version while users keep browsing with no error pages and no maintenance screen. You do it by starting the new version, confirming it is healthy, and only then switching traffic to it — all automated through CI/CD.

Why manual deploys quietly cost you money

Teams that SSH in, pull code, and restart the server pay for it in three ways: visible downtime during every release, human error at 2am, and engineers who avoid deploying because it's stressful — so fixes ship late. Automating the pipeline removes all three.

The pieces of the pipeline

1. Containerise with Docker

A Dockerfile packages your app and its exact dependencies so "works on my machine" becomes "works everywhere." The same image that passed tests is the image that runs in production — no drift.

2. Build and test in GitHub Actions

On every push, GitHub Actions builds the image, runs your test suite, and pushes the image to a registry. If tests fail, the deploy never happens.

name: Deploy
on:
  push: { branches: [main] }
jobs:
  ship:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Build image
        run: docker build -t app:${{ github.sha }} .
      - name: Run tests
        run: docker run --rm app:${{ github.sha }} php artisan test
      - name: Deploy over SSH
        run: ssh deploy@server "cd /srv/app && ./deploy.sh ${{ github.sha }}"

3. Blue-green switch with a health check

On the server, the deploy script starts the new container ("green") alongside the running one ("blue"), waits until /health returns 200, then points the reverse proxy (Nginx or Traefik) at green and retires blue. If the health check never passes, traffic stays on blue and the release aborts — automatic rollback.

The health check is the whole game

Zero downtime depends entirely on not switching traffic to a broken version. A good health-check endpoint confirms the app boots, the database connects, and the cache responds — not just that the web server is up. This single endpoint is what makes automated rollback safe.

Do you need Kubernetes?

Usually not. Kubernetes gives rolling updates for free but adds a steep operational cost. For most apps, a single well-configured VPS with Docker Compose and a health-checked blue-green script delivers the same zero-downtime result for a fraction of the money and maintenance. Move to Kubernetes when scale genuinely demands it — not before.

Get it set up once, benefit forever

A proper pipeline turns deployment from a dreaded event into a non-event you do several times a day. This is core DevOps & cloud engineering work I include with every Laravel build. Want your deploys automated and downtime gone? Message me on WhatsApp for a fixed quote within 24 hours.

DevOpsDockerCI/CDGitHub ActionsBangladesh

Frequently asked

It is releasing a new version of your app while it keeps serving users without interruption. The new version is started and health-checked before traffic switches to it, so visitors never see an error page or a maintenance screen during a deploy.

No. Kubernetes gives you rolling updates out of the box, but a single VPS with Docker Compose, a reverse proxy, and a health-checked blue-green script achieves zero downtime for most small and mid-sized apps at a fraction of the complexity and cost.

A well-built CI/CD pipeline builds, tests, and deploys in a few minutes, fully automated, with rollback on failure. If your deploys take hours or need manual steps, that is a process problem worth fixing first.

Chat with Jakiur