CI/CD & Deployment

Deployment Strategies

The gitlabdiscussions project utilizes two deployment strategies:

  1. Production: This strategy deploys code to the production environment, which is the live instance of GitLab.
  2. Staging: This strategy deploys code to a staging environment, which is a replica of the production environment used for testing and validation before deploying to production.

Deployment Methods

The following deployment methods are used within the project:

  1. Automated Deployments: The primary deployment method utilizes GitLab CI/CD pipelines, automating deployments triggered by code changes.

    • Code: -/.gitlab-ci.yml

    • Triggering: Pipelines are triggered on merge requests to the main branch, ensuring code quality checks and automatic deployments.

    • Workflow: The pipeline handles building, testing, and deploying the application.

  2. Manual Deployments: In specific cases, manual deployments might be required for troubleshooting or emergency updates.

    • Method: Manual deployments are triggered using the GitLab interface.

    • Documentation: This approach is documented in the relevant project wiki page.

Environment Configuration

The following outlines the configuration for the production and staging environments:

  1. Production: The production environment utilizes the production database, which holds all user data and activity related to the discussions feature.

    • Configuration: Production configuration is managed through environment variables defined in GitLab.

    • Code: Environment variables are referenced in the application code.

    • Security: Production environment access is restricted to authorized personnel.

  2. Staging: The staging environment utilizes a separate database, which is a replica of the production database, enabling testing without affecting production data.

    • Configuration: Staging environment configuration is managed through environment variables defined in GitLab.

    • Code: Environment variables are referenced in the application code.

Deployment Process

The following steps outline the general deployment process:

  1. Code Changes: Developers push code changes to the main branch.

  2. Pipeline Trigger: GitLab CI/CD pipeline is triggered, initiating automated testing and building.

  3. Testing: The pipeline runs tests to ensure the code quality meets the project standards.

    • Tests: Unit tests, integration tests, and end-to-end tests are executed.
  4. Deployment: If all tests pass, the pipeline proceeds to deploy the code to the selected environment (staging or production).

    • Staging Deployment: Deploying to staging allows for testing and validation in a near-production environment.

    • Production Deployment: Once validated, the code is deployed to production.

  5. Deployment Confirmation: The pipeline checks the deployed application’s status and confirms its successful deployment.

Monitoring & Rollbacks

The project utilizes the following mechanisms for monitoring and rolling back deployments:

  1. Monitoring: Monitoring tools track application performance and detect potential issues.

    • Tools: GitLab’s built-in monitoring features and external monitoring services are used.

    • Alerting: Alerts are configured to notify developers of any issues or anomalies.

  2. Rollbacks: In case of deployment issues, the project allows for rolling back to previous versions of the code.

    • Method: The GitLab CI/CD pipeline allows for rolling back to previous deployments.

Branching Strategy

The project uses a Git flow branching strategy:

  1. Main Branch: This branch contains the latest stable version of the code, representing the live production environment.

  2. Feature Branches: Developers create feature branches for developing new features or fixing bugs.

  3. Merge Requests: Developers create merge requests to merge their feature branches into the main branch after code review and testing.

    • Review: Code review is conducted by other developers to ensure code quality and adherence to project standards.
  4. Deployment Trigger: Merging a feature branch into the main branch triggers a deployment pipeline.

This strategy allows for a structured and controlled development process, ensuring the stability of the production environment.