Skip to main content

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

·1 min read

by Frank Doka

Article

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

Phase 2 packages the web server into a portable container — ready to run identically on a laptop or an EC2 instance.

What I Built

  1. Static site — Simple HTML/CSS page. The focus is on the pipeline, not the frontend.
  2. NGINX configuration — Configured NGINX to serve the static content over HTTPS using a self-signed OpenSSL certificate.
  3. Dockerfile — Multi-step build: installs NGINX, generates the SSL certificate, copies the site content and NGINX config into the image.
  4. Local testing — Ran docker build and docker run locally, hit https://localhost, confirmed the certificate was served and the page rendered correctly.
  5. Docker Hub push — Tagged and pushed the image to Docker Hub so Ansible can pull it onto EC2 in Phase 4.

What's Next

Phase 3 uses Terraform to provision the EC2 instance that will host this container.

More articles

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

Jenkins orchestrates the full pipeline — Terraform provisioning, Ansible configuration, container deployment, and smoke testing on every Git push.

Read more

CI/CD Pipeline for NGINX on Docker — Phase 1: Architecture & Tools

Overview of the four-tool automation stack — Docker, Terraform, Ansible, and Jenkins — and how they fit together in the pipeline.

Read more