Ismet Seyhan

Computer Engineer

Back-end Developer

Front-end Developer

Mobile Developer

Entrepreneur

Freelancer

0

No products in the cart.

Ismet Seyhan
Ismet Seyhan
Ismet Seyhan
Ismet Seyhan
Ismet Seyhan

Computer Engineer

Back-end Developer

Front-end Developer

Mobile Developer

Entrepreneur

Freelancer

Blog Post

Git Branch-Based CI/CD Workflow with Docker, Self-Hosted Agents, Nginx, SSL, and Azure Pipelines

September 5, 2023 Uncategorized

In the realm of modern software development, establishing a seamless and efficient Continuous Integration and Continuous Deployment (CI/CD) process is paramount for delivering reliable and up-to-date applications.

One effective method to achieve this goal is by using a mix of advanced technologies: Docker, self-hosted agents, Nginx reverse proxy, SSL, and Azure Pipelines. In this detailed guide, we’ll explore an approach that I’ve personally employed in my projects, focusing on a branch-based deployment process that fits perfectly within Azure DevOps or Jira-based workflows.

Within my scenario, two distinct environments come into play: 

The Live environment housing the operational backend services

The Staging environment where developers can test their enhancements.

The ultimate objective is twofold:

Firstly, to facilitate the automatic generation of a new version in the live environment whenever a new feature is merged into the main branch, and secondly, to mirror this process in the staging environment each time a development merge occurs within the staging branch.

Also, Instead of direct IP addresses of Servers, my plan involves accessing these environments via domains. Specifically, utilizing api.domainname.com to access the backend services in the live environment and staging.domainname.com to access the backend services in the staging environment. We’ll also implement SSL certificates for enhanced data protection. This approach not only enhances accessibility but also contributes to a more seamless and organized workflow.

Now, let’s simplify and summarise what we have

  • Backend Project: Asp .Net Core 7
  • Database: PostgreSQL
  • API Documentation: Swagger
  • DevOps: Azure DevOps
  • Version Control System: Git
  • Environments: Live and Staging/test
  • Servers: 2 Azure EC2 Linux Ubuntu
  • Based Branches: main, staging-env
  • Subdomains: api.domainname.com, staging.domainname.com
  • SSL: OpenSSL or GeoTrust

Workflow Process:

Main Branch — Live Environment

  1. Developers create new features or make changes in feature branches.
  2. Once the changes are ready, a pull request is created and submitted for review.
  3. After code review and approval, the pull request is merged into the main branch.
  4. Azure Pipelines are triggered automatically by the merge.
  5. Azure Pipelines execute the following steps:
  • Dockerize your backend project, creating a containerized version.
  • Push the Docker image to a Docker Hub.
  • Pull the updated Docker image in the live environment.
  • Republish the backend services with the new image, effectively updating the live environment with the latest changes.

6. Database: Live Database 7. Swagger: Deactivated

Staging Branch — Staging Environment:

  1. Developers create and test new features or changes in feature branches.
  2. Similar to the main branch workflow, a pull request is created and reviewed.
  3. Upon approval, the pull request is merged into the staging branch.
  4. Azure Pipelines are automatically triggered.
  5. The Azure Pipelines process for the staging environment mirrors the steps of the live environment:
  • Dockerize the backend project.
  • Push the Docker image to a Docker Hub.
  • Pull the updated Docker image in the staging environment.
  • Republish the backend services with the new image, updating the staging environment for testing.

6. Database: Staging/Test Database 7. Swagger: Activated

Write a comment