๐ Project Overview
This project demonstrates:
- Provisioning a local Docker containerย running Nginx usingย Terraform.
- Usingย Git branching strategyย to manage multiple versions of the project.
- Tagging versions in Git for release management.
๐ Branch Structure
We are using three branches:
| Branch Name | Purpose | Project Content |
|---|---|---|
| main | Stable production-ready code. | Contains the final tested project that provisions an Nginx container via Terraform. |
| dev | Development environment for ongoing work. | Same core functionality as main but used for testing new changes before merging. |
| feature-add-index | Experimental feature branch for adding a custom index.html page in the Nginx container. | Includes Terraform code + a mounted custom HTML file. |
๐ Why We Use Branches
- Isolationย โ Work on new features without breaking production.
- Parallel Developmentย โ Multiple developers can work on different tasks simultaneously.
- Safe Testingย โ Test changes inย
devย orยfeatureย before merging intoยmain.
๐ How Branch Projects Differ
- mainย โ Only deploys a default Nginx container.
- devย โ Mirrors main but used for intermediate testing.
- feature-add-indexย โ Adds a mounted HTML file for custom homepage.
Note: In our current setup,
devandfeature-add-indexhave similar Terraform structure, butfeature-add-indexcontains additional files for the custom index page.
๐ท๏ธ Why We Use Tags
Tags are used to:
- Markย release versionsย (e.g.,ย
v1.0). - Quickly roll back to a known working state.
- Provide a reference for deployment without using a branch.
๐ Example Tagging Commands
# Create a tag git tag v1.0 # Push tag to remote git push origin v1.0 ๐ ๏ธ How to Test Each Branch bash Copy Edit # Clone the repository git clone https://github.com/jaspreet237/terraform-docker-nginx-gitflow.git cd terraform-docker-nginx-gitflow # Switch to a branch git checkout main # or dev / feature-add-index # Initialize Terraform terraform init # Plan and apply terraform plan terraform apply -auto-approve # Access Nginx http://localhost:8081 ๐ Tasks Completed in This Project Created Git repository and connected it to GitHub. Created multiple branches (main, dev, feature-add-index). Implemented Terraform configuration to run Nginx in Docker. Tested all branches to verify they work independently. Added Git tags to mark release versions. Documented the project in Markdown for better understanding. ๐ฆ Tech Stack Terraform โ Infrastructure as Code (IaC) Docker โ Containerized Nginx server Git โ Version control GitHub โ Remote repository hosting
