{"id":283,"date":"2025-08-26T09:06:02","date_gmt":"2025-08-26T09:06:02","guid":{"rendered":"https:\/\/myallcodes.in\/?p=283"},"modified":"2025-12-02T17:41:51","modified_gmt":"2025-12-02T17:41:51","slug":"terraform-docker-nginx-git-branching-workflow","status":"publish","type":"post","link":"https:\/\/myallcodes.in\/index.php\/2025\/08\/26\/terraform-docker-nginx-git-branching-workflow\/","title":{"rendered":"Terraform + Docker + Nginx + Git Branching Workflow"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\ud83d\udccc Project Overview<\/h2>\n\n\n\n<p><a href=\"https:\/\/github.com\/jaspreet237\/terraform-docker-nginx-gitflow#-project-overview\"><\/a><\/p>\n\n\n\n<p>This project demonstrates:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Provisioning a local Docker container<\/strong>\u00a0running Nginx using\u00a0<strong>Terraform<\/strong>.<\/li>\n\n\n\n<li>Using\u00a0<strong>Git branching strategy<\/strong>\u00a0to manage multiple versions of the project.<\/li>\n\n\n\n<li>Tagging versions in Git for release management.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udcc2 Branch Structure<\/h2>\n\n\n\n<p><a href=\"https:\/\/github.com\/jaspreet237\/terraform-docker-nginx-gitflow#-branch-structure\"><\/a><\/p>\n\n\n\n<p>We are using three branches:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Branch Name<\/th><th>Purpose<\/th><th>Project Content<\/th><\/tr><\/thead><tbody><tr><td><strong>main<\/strong><\/td><td>Stable production-ready code.<\/td><td>Contains the final tested project that provisions an Nginx container via Terraform.<\/td><\/tr><tr><td><strong>dev<\/strong><\/td><td>Development environment for ongoing work.<\/td><td>Same core functionality as main but used for testing new changes before merging.<\/td><\/tr><tr><td><strong>feature-add-index<\/strong><\/td><td>Experimental feature branch for adding a custom&nbsp;<code>index.html<\/code>&nbsp;page in the Nginx container.<\/td><td>Includes Terraform code + a mounted custom HTML file.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udd0d Why We Use Branches<\/h2>\n\n\n\n<p><a href=\"https:\/\/github.com\/jaspreet237\/terraform-docker-nginx-gitflow#-why-we-use-branches\"><\/a><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Isolation<\/strong>\u00a0\u2192 Work on new features without breaking production.<\/li>\n\n\n\n<li><strong>Parallel Development<\/strong>\u00a0\u2192 Multiple developers can work on different tasks simultaneously.<\/li>\n\n\n\n<li><strong>Safe Testing<\/strong>\u00a0\u2192 Test changes in\u00a0<code>dev<\/code>\u00a0or\u00a0<code>feature<\/code>\u00a0before merging into\u00a0<code>main<\/code>.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83c\udd9a How Branch Projects Differ<\/h2>\n\n\n\n<p><a href=\"https:\/\/github.com\/jaspreet237\/terraform-docker-nginx-gitflow#-how-branch-projects-differ\"><\/a><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>main<\/strong>\u00a0\u2192 Only deploys a default Nginx container.<\/li>\n\n\n\n<li><strong>dev<\/strong>\u00a0\u2192 Mirrors main but used for intermediate testing.<\/li>\n\n\n\n<li><strong>feature-add-index<\/strong>\u00a0\u2192 Adds a mounted HTML file for custom homepage.<\/li>\n<\/ul>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p><strong>Note:<\/strong>&nbsp;In our current setup,&nbsp;<code>dev<\/code>&nbsp;and&nbsp;<code>feature-add-index<\/code>&nbsp;have similar Terraform structure, but&nbsp;<code>feature-add-index<\/code>&nbsp;contains additional files for the custom index page.<\/p>\n<\/blockquote>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83c\udff7\ufe0f Why We Use Tags<\/h2>\n\n\n\n<p><a href=\"https:\/\/github.com\/jaspreet237\/terraform-docker-nginx-gitflow#%EF%B8%8F-why-we-use-tags\"><\/a><\/p>\n\n\n\n<p>Tags are used to:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Mark\u00a0<strong>release versions<\/strong>\u00a0(e.g.,\u00a0<code>v1.0<\/code>).<\/li>\n\n\n\n<li>Quickly roll back to a known working state.<\/li>\n\n\n\n<li>Provide a reference for deployment without using a branch.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83d\udccc Example Tagging Commands<\/h2>\n\n\n\n<p><a href=\"https:\/\/github.com\/jaspreet237\/terraform-docker-nginx-gitflow#-example-tagging-commands\"><\/a><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># Create a tag\ngit tag v1.0\n\n# Push tag to remote\ngit push origin v1.0\n\ud83d\udee0\ufe0f How to Test Each Branch\nbash\nCopy\nEdit\n# Clone the repository\ngit clone https:\/\/github.com\/jaspreet237\/terraform-docker-nginx-gitflow.git\ncd terraform-docker-nginx-gitflow\n\n# Switch to a branch\ngit checkout main      # or dev \/ feature-add-index\n\n# Initialize Terraform\nterraform init\n\n# Plan and apply\nterraform plan\nterraform apply -auto-approve\n\n# Access Nginx\nhttp:\/\/localhost:8081\n\ud83d\udcdc Tasks Completed in This Project\nCreated Git repository and connected it to GitHub.\n\nCreated multiple branches (main, dev, feature-add-index).\n\nImplemented Terraform configuration to run Nginx in Docker.\n\nTested all branches to verify they work independently.\n\nAdded Git tags to mark release versions.\n\nDocumented the project in Markdown for better understanding.\n\n\ud83d\udce6 Tech Stack\nTerraform \u2192 Infrastructure as Code (IaC)\n\nDocker \u2192 Containerized Nginx server\n\nGit \u2192 Version control\n\nGitHub \u2192 Remote repository hosting<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\ud83d\udccc Project Overview This project demonstrates: \ud83d\udcc2 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\u2026 <span class=\"read-more\"><a href=\"https:\/\/myallcodes.in\/index.php\/2025\/08\/26\/terraform-docker-nginx-git-branching-workflow\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[25],"tags":[],"class_list":["post-283","post","type-post","status-publish","format-standard","hentry","category-miscellaneous"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/myallcodes.in\/index.php\/wp-json\/wp\/v2\/posts\/283","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/myallcodes.in\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/myallcodes.in\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/myallcodes.in\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/myallcodes.in\/index.php\/wp-json\/wp\/v2\/comments?post=283"}],"version-history":[{"count":1,"href":"https:\/\/myallcodes.in\/index.php\/wp-json\/wp\/v2\/posts\/283\/revisions"}],"predecessor-version":[{"id":284,"href":"https:\/\/myallcodes.in\/index.php\/wp-json\/wp\/v2\/posts\/283\/revisions\/284"}],"wp:attachment":[{"href":"https:\/\/myallcodes.in\/index.php\/wp-json\/wp\/v2\/media?parent=283"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/myallcodes.in\/index.php\/wp-json\/wp\/v2\/categories?post=283"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/myallcodes.in\/index.php\/wp-json\/wp\/v2\/tags?post=283"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}