One goal is to make deployments in different environments. Ability to get changes, including new features, configuration fixes and experiments into production or other environments in a sustainable way.
Environments
Requirements
Flow
If a developer updates new features to their working in progress branch, automatic deployments to the environments.
build (backend/frontend) > containerized > deploy to target server
Deployment scripts are defined in .gitlab-ci.yml in the working repository.
Gitlab CI/CD
For reference: https://docs.gitlab.com/ee/ci/
Gitlab Runner
Gitlab runner run the deployment scripts in the .gitlab-ci.yml
Install gitlab-runner
For reference: https://docs.gitlab.com/runner/
curl -L "https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh" | sudo bash
sudo apt-get install gitlab-runner
systemctl status gitlab-runner
Register a gitlab-runner to gitlab application
Go to project repository > Settings > CI/CD > Runner
To register a runner, go to the server where the gitlab-runner is installed.
In the terminal, run:
gitlab-runner register
It will ask for the gitlab-url
It will ask for the token, paste the token provided in the CI/CD > Runner Settings
Add the maintenance note
Gitlab-runner is under maintenance!
Specify tags to be used in .gitlab-ci.yml file.
tag1, tag2, tag3
Specify the gitlab-runner executor
For your reference: https://docs.gitlab.com/runner/executors/
Wait for the message that gitlab-runner is successufully registered, you can also check in the Settings > CI/CD > Runners if the gitlab-runner is online and available.
.gitlab-ci.yml
For your reference: https://docs.gitlab.com/ee/ci/quick_start/
Sample format
stages:
- build
- deploy
- test
build-uat-env:
stage: build
script:
- define scripts here to build the application
tags:
- define tags on w/c runner should execute this jobdeploy-uat-env:
stage: deploy
script:
- define scripts here to deploy the application to the target server
tags:
- define tags on w/c runner should execute this jobbuild-test-env:
stage: build
script:
- define scripts here to build the application
tags:
- define tags on w/c runner should execute this jobdeploy-test-env:
stage: deploy
script:
- define scripts here to deploy the application to the target server
tags:
- define tags on w/c runner should execute this jobbuild-sandbox-env:
stage: build
script:
- define scripts here to build the application
tags:
- define tags on w/c runner should execute this jobdeploy-sandbox-env:
stage: deploy
script:
- define scripts here to deploy the application to the target server
tags:
- define tags on w/c runner should execute this jobbuild-prod-env:
stage: build
script:
- define scripts here to build the application
tags:
- define tags on w/c runner should execute this jobdeploy-prod-env:
stage: deploy
script:
- define scripts here to deploy the application to the target server
tags:
- define tags on w/c runner should execute this jobcypress-test:
stage: test
script:
- define scripts here on how to install and run test cases in cypress