This project demonstrates foundational DevOps principles by deploying an Nginx web server using three distinct, progressively complex patterns. It uses Docker, Docker Compose, Python, and LocalStack to simulate a real-world cloud environment on a local machine, showcasing a journey from basic containerization to advanced, programmatic automation.
- Infrastructure as Code (IaC): Implemented both declarative (Docker Compose) and imperative (Python script) approaches, highlighting the trade-offs of each.
- Containerization & Orchestration: Created custom, multi-stage Docker images and managed a multi-container application stack with Docker Compose.
- Cloud Services Simulation: Leveraged LocalStack to mimic AWS S3 for dynamic content hosting, enabling development and testing of cloud-native patterns without an AWS account.
- Automation & Scripting: Developed a Python script using the Docker SDK (
docker-py
) to programmatically manage the entire application lifecycle, from network creation to container provisioning and cleanup. - Decoupled Architecture: Refactored a monolithic application into a dynamic system where the web server fetches its content from an object store (S3) on startup via a custom entrypoint script.
- Configuration Management: Utilized environment variables to pass configuration (API endpoints, credentials, bucket names) into containers, following Twelve-Factor App principles.
- Container Networking: Configured service-to-service communication between containers on a user-defined Docker network.
- Containerization: Docker, Docker Compose
- Cloud (Simulated): LocalStack (emulating AWS S3)
- Automation: Python 3, Docker SDK (
docker-py
), Bash Scripting - Web Server: Nginx
- CLI Tools: AWS CLI
This repository is divided into three parts, each located in its own directory and representing a different deployment pattern.
A simple, self-contained Nginx deployment where the website content is built directly into the Docker image.
To Run:
cd part1-declarative-basic
docker-compose up -d
Access the site at http://localhost:8080
An advanced pattern where the Nginx container is generic and dynamically fetches its index.html file from a LocalStack S3 bucket on startup.
To Run:
cd part2-declarative-dynamic
docker-compose up -d localstack
Note: Ensure you have dummy AWS credentials configured for the CLI.
aws --endpoint-url=http://localhost:4566 s3 mb s3://my-dynamic-website-bucket
aws --endpoint-url=http://localhost:4566 s3 cp ./nginx-web/index.html s3://my-dynamic-website-bucket/
docker-compose up -d nginx-service
Access the site at http://localhost:8080
A Python script that uses the Docker SDK to build the entire environment from scratch. This script handles network creation, container provisioning (installing Nginx inside a bare Ubuntu container), and deployment. To Run:
cd part3-imperative-python
pip install docker
python3 deploy.py
Access the site at http://localhost:8081.
run python3 cleanup.py.
This diagram illustrates the dynamic content flow, where the Nginx container is decoupled from its content.