Skip to main content

CI/CD Pipeline for NGINX on Docker — Phase 5: Automated Deployments with Jenkins

·2 min read

by Frank Doka

Article

CI/CD Pipeline for NGINX on Docker — Phase 5: Automated Deployments with Jenkins

Phase 5 ties the entire stack together: one Git push triggers infrastructure provisioning, server configuration, container deployment, and a smoke test — fully automated.

Jenkins Pipeline Stages

  1. Checkout — Pull the latest code from the Git repository.
  2. Terraform Apply — Provision or update the EC2 infrastructure. If the instance already exists and nothing changed, Terraform skips it.
  3. Ansible Playbook — Using the Ansible plugin, Jenkins runs the configuration playbook. Dynamic inventory discovers the current EC2 instance, SSHs in, and ensures Docker is installed and the latest container image is running.
  4. Smoke Test — A basic HTTP check against the deployed instance confirms NGINX is responding with a 200 status code.

If any stage fails, the pipeline stops and the build is marked red.

How It Works

Jenkins runs locally and watches the Git repository. On each push to main, it triggers the pipeline automatically. No manual SSH, no clicking through consoles, no remembering which commands to run in which order.

Project Takeaways

Building this pipeline taught me how four independent tools — Docker, Terraform, Ansible, and Jenkins — compose into a single automated delivery system. Each tool owns exactly one responsibility, and Jenkins orchestrates the handoffs. The result: push code, get a verified deployment.

More articles

CI/CD Pipeline for NGINX on Docker — Phase 4: Ansible & Dynamic Inventory

Configuring EC2 instances with Ansible playbooks and AWS dynamic inventory — installing Docker and deploying the container without hardcoded hosts.

Read more

CI/CD Pipeline for NGINX on Docker — Phase 2: Creating the Docker Image

Writing the Dockerfile, bundling NGINX with a self-signed OpenSSL certificate, testing locally, and pushing to Docker Hub.

Read more