146 lines
3.5 KiB
Markdown
146 lines
3.5 KiB
Markdown
# Simple CI/CD Demo with Docker, Nginx, and GitLab CI
|
|
|
|
This repository demonstrates a **minimal end-to-end CI/CD pipeline** using **Docker**, **Nginx**, and **GitLab CI/CD**.
|
|
The project intentionally uses a **very simple static webpage** to focus on illustrating the **build, registry, and deployment workflow** rather than application complexity.
|
|
|
|
---
|
|
|
|
## Overview
|
|
|
|
The repository contains a small static website served by **Nginx running in a Docker container**.
|
|
A **GitLab CI/CD pipeline** automatically builds the Docker image, pushes it to the container registry, and deploys it to a remote server.
|
|
|
|
This setup demonstrates a **complete CI/CD lifecycle**:
|
|
|
|
1. Developer pushes code to the repository
|
|
2. GitLab CI pipeline triggers automatically
|
|
3. Docker image is built from the `Dockerfile`
|
|
4. Image is pushed to the container registry
|
|
5. Deployment server pulls the new image
|
|
6. Container is started or updated on the server
|
|
|
|
---
|
|
|
|
## Repository Structure
|
|
```
|
|
.
|
|
├── index.html # Simple static webpage
|
|
├── Dockerfile # Builds the Nginx container
|
|
├── .gitlab-ci.yml # CI/CD pipeline configuration
|
|
└── README.md # Project documentation
|
|
```
|
|
|
|
---
|
|
|
|
## Application
|
|
|
|
The application consists of a **single static HTML page** served by **Nginx**.
|
|
|
|
The page is packaged inside a Docker container and served via an **Nginx server running on Alpine Linux**, providing a lightweight and efficient runtime environment.
|
|
|
|
---
|
|
|
|
## Docker Setup
|
|
|
|
The `Dockerfile` builds a container using:
|
|
|
|
- **Nginx**
|
|
- **Alpine Linux base image**
|
|
- The static `index.html` copied into the default Nginx web directory
|
|
|
|
Typical responsibilities of the container:
|
|
|
|
- Start an Nginx server
|
|
- Serve the static HTML page
|
|
- Expose the HTTP port
|
|
|
|
---
|
|
|
|
## CI/CD Pipeline
|
|
|
|
The `.gitlab-ci.yml` file defines the automated pipeline used by **GitLab CI/CD**.
|
|
|
|
### Pipeline Stages
|
|
|
|
1. **Build**
|
|
- Builds the Docker image from the repository's `Dockerfile`.
|
|
|
|
2. **Push**
|
|
- Tags and pushes the image to the **GitLab Container Registry**.
|
|
|
|
3. **Deploy**
|
|
- Connects to the deployment server using **SSH**
|
|
- Pulls the latest image from the registry
|
|
- Runs (or replaces) the container on the server
|
|
|
|
---
|
|
|
|
## Deployment Flow
|
|
|
|
```
|
|
Developer Push
|
|
│
|
|
▼
|
|
GitLab CI Pipeline
|
|
│
|
|
├── Build Docker Image
|
|
│
|
|
├── Push to Container Registry
|
|
│
|
|
▼
|
|
Deployment Server (SSH)
|
|
│
|
|
├── Pull Latest Image
|
|
└── Run Container
|
|
```
|
|
|
|
|
|
---
|
|
|
|
## Purpose of This Repository
|
|
|
|
This repository serves as a **minimal working example of a CI/CD pipeline** that demonstrates:
|
|
|
|
- Containerizing a web application
|
|
- Automating builds using GitLab CI
|
|
- Publishing Docker images to a registry
|
|
- Deploying containers remotely using SSH
|
|
|
|
Because the application itself is intentionally simple, the focus remains on **understanding the CI/CD workflow**.
|
|
|
|
---
|
|
|
|
## Use Cases
|
|
|
|
This project can be used for:
|
|
|
|
- Learning CI/CD fundamentals
|
|
- Demonstrating Docker build pipelines
|
|
- Testing GitLab CI deployment strategies
|
|
- Teaching DevOps workflows with minimal complexity
|
|
|
|
---
|
|
|
|
## Requirements
|
|
|
|
To run or adapt this pipeline you typically need:
|
|
|
|
- GitLab repository with CI/CD enabled
|
|
- GitLab Container Registry access
|
|
- Docker installed on the deployment server
|
|
- SSH access configured for CI/CD deployment
|
|
|
|
---
|
|
|
|
## Summary
|
|
|
|
This project demonstrates a **simple but complete DevOps workflow**:
|
|
|
|
- Static web page
|
|
- Dockerized with Nginx (Alpine base)
|
|
- Automated build and registry push
|
|
- Remote deployment via GitLab CI/CD
|
|
|
|
It provides a clear and lightweight example of **how CI/CD pipelines automate containerized application delivery**.
|
|
|