Overview

The production deployment process for gitlab-org/… is orchestrated through a series of stages that involve building, testing, and deploying code in a reliable manner. This document outlines the step-by-step process to achieve a stable deployment to production.

Prerequisites

Before starting the deployment process, ensure that the following prerequisites are met:

  • Appropriate access to the production environment.
  • Necessary configuration set up in the CI/CD pipeline.
  • All environment variables securely managed.

Step-by-Step Deployment Process

1. Preparation

Run the following commands to ensure you have the latest changes and are working on the correct branch.

git fetch origin
git checkout main
git pull origin main

2. Build and Test

Execute the build and test process to verify that all functionalities are working as intended.

# Run all tests
make test

Verify that there are no failing tests. If any tests fail, address those issues before proceeding.

3. Continuous Integration (CI) Pipeline

The CI pipeline script is defined in the .gitlab-ci.yml file. Make sure the pipeline is correctly configured to deploy to the production environment.

Trigger the CI pipeline:

git push origin main

Monitor the pipeline in the GitLab UI to ensure all stages complete successfully.

4. Production Configuration

Ensure that all production-specific configurations are in place. This includes checking the configuration files and updating any environment variables required for production.

Example configuration file updates:

# config/production.yml
production:
  database:
    adapter: postgres
    encoding: unicode
    database: my_app_production
    username: <%= ENV['DB_USERNAME'] %>
    password: <%= ENV['DB_PASSWORD'] %>

5. Deploy to Production

Once the CI pipeline has completed successfully, proceed with the deployment. The production deployment can be triggered manually or automatically, depending on the setup.

To deploy manually, execute the following command:

make deploy

Ensure that the deployment scripts handle migrations and any necessary pre-deploy tasks such as caching.

6. Database Migrations

If there are any database migrations to be applied, run the migration command at this stage:

rails db:migrate RAILS_ENV=production

Double-check to confirm that all migrations apply successfully.

7. Validate Deployment

After deployment, it is crucial to validate that the application is running smoothly in the production environment. This can be done by checking the application logs and health checks.

Use the following command to view logs:

tail -f log/production.log

Access the application in a browser to confirm that the latest version is live.

8. Rollback Procedures

In the event of a failed deployment, rollback to the previous stable release can be performed using:

git checkout <previous_commit_hash>
make deploy

Ensure that you have backups of your database and essential files to restore to a previous state if necessary.

9. Post-Deployment Monitoring

Set up monitoring tools to track application performance, errors, and user feedback. This ensures that any potential issues are addressed promptly after deployment.

Utilize tools such as:

- Prometheus for metrics
- Grafana for dashboards
- Sentry for error tracking

Conclusion

Following the above steps ensures a smooth and reliable deployment to production for gitlab-org/… Ensure that each step is followed meticulously, and always troubleshoot issues as they arise before proceeding.

This outline was derived from established deployment practices within the gitlab-org/… team and serves as a reference for developers engaged in the deployment process.