CI/CD & Deployment
Deployment Strategies
The gitlabdiscussions
project utilizes two deployment strategies:
- Production: This strategy deploys code to the production environment, which is the live instance of GitLab.
- 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:
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.
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:
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.
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:
Code Changes: Developers push code changes to the
main
branch.Pipeline Trigger: GitLab CI/CD pipeline is triggered, initiating automated testing and building.
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.
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.
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:
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.
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:
Main Branch: This branch contains the latest stable version of the code, representing the live production environment.
Feature Branches: Developers create feature branches for developing new features or fixing bugs.
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.
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.