mirror of
https://github.com/OneUptime/oneuptime
synced 2024-11-22 15:24:55 +00:00
99 lines
3.9 KiB
YAML
Executable File
99 lines
3.9 KiB
YAML
Executable File
# IMPORTANT:
|
|
#
|
|
# This CI/CD will run on an Ubuntu VM. After this script runs, the VM will retain the state.
|
|
# It's your responsibility to clean the VM up in the cleanup stage after job finishes executing.
|
|
# This script runs on Microk8s. since our deployments are on Kubernetes, our aim is to create EXACT same replica for test, staging and production.
|
|
|
|
#Define stages
|
|
stages:
|
|
- build_n_test
|
|
- e2e_test
|
|
- deploy_staging
|
|
- deploy_production
|
|
|
|
build_n_test:
|
|
stage: build_n_test
|
|
script:
|
|
- sudo docker stop $(sudo docker ps -aq) || echo 'No docker containers'
|
|
- sudo docker rm $(sudo docker ps -aq) || echo 'No docker containers'
|
|
- sudo docker run --name mongo -p 27017:27017 -d mongo:3.4
|
|
- sudo docker build -t fyipe-project/fyipe-backend:1.0.$CI_PIPELINE_IID .
|
|
- sudo docker run --name fyipe --network container:mongo fyipe-project/fyipe-backend:1.0.$CI_PIPELINE_IID npm test
|
|
|
|
e2e_test:
|
|
stage: e2e_test
|
|
script:
|
|
- sudo rm -r *
|
|
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/fyipe-project/kubernetes
|
|
- cd kubernetes
|
|
- chmod +x ./ci/setup-machine.sh
|
|
- ./ci/setup-machine.sh
|
|
- chmod +x ./ci/setup.sh
|
|
- ./ci/setup.sh
|
|
- BACKEND_CONTAINER=`sudo kubectl get pods -l app=fyipe-backend -o custom-columns=:metadata.name`
|
|
- sudo kubectl get pod BACKEND_CONTAINER=
|
|
only:
|
|
refs:
|
|
- release
|
|
- master
|
|
|
|
deploy_staging:
|
|
stage: deploy_staging
|
|
script:
|
|
- sudo rm -r *
|
|
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/fyipe-project/kubernetes
|
|
- cd kubernetes
|
|
- chmod +x ./ci/deployment-setup.sh
|
|
- ./ci/deployment-setup.sh
|
|
- chmod +x ./ci/deployment-staging-setup.sh
|
|
- ./ci/deployment-staging-setup.sh
|
|
- cd ..
|
|
- git clone https://$GIT_USERNAME:$GIT_PASSWORD@gitlab.com/fyipe-project/fyipe-backend.git
|
|
- cd fyipe-backend
|
|
- git checkout master
|
|
- sudo docker build -t fyipe-project/fyipe-backend:master .
|
|
- sudo docker tag fyipe-project/fyipe-backend:master registry.gitlab.com/fyipe-project/fyipe-backend:2.0.$CI_PIPELINE_IID
|
|
- sudo docker tag fyipe-project/fyipe-backend:master registry.gitlab.com/fyipe-project/fyipe-backend:master
|
|
- sudo docker push registry.gitlab.com/fyipe-project/fyipe-backend:2.0.$CI_PIPELINE_IID
|
|
- sudo docker push registry.gitlab.com/fyipe-project/fyipe-backend:master
|
|
- sudo $HOME/google-cloud-sdk/bin/kubectl set image deployment/fyipe-backend fyipe-backend=registry.gitlab.com/fyipe-project/fyipe-backend:2.0.$CI_PIPELINE_IID
|
|
- cd ..
|
|
- cd kubernetes
|
|
- chmod +x ./ci/deployment-cleanup.sh
|
|
- ./ci/deployment-cleanup.sh
|
|
only:
|
|
refs:
|
|
- master
|
|
environment:
|
|
name: staging
|
|
|
|
deploy_production:
|
|
stage: deploy_production
|
|
script:
|
|
- sudo rm -r *
|
|
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.com/fyipe-project/kubernetes
|
|
- cd kubernetes
|
|
- chmod +x ./ci/deployment-setup.sh
|
|
- ./ci/deployment-setup.sh
|
|
- chmod +x ./ci/deployment-production-setup.sh
|
|
- ./ci/deployment-production-setup.sh
|
|
- cd ..
|
|
- git clone https://$GIT_USERNAME:$GIT_PASSWORD@gitlab.com/fyipe-project/fyipe-backend.git
|
|
- cd fyipe-backend
|
|
- git checkout release
|
|
- sudo docker build -t fyipe-project/fyipe-backend:latest .
|
|
- sudo docker tag fyipe-project/fyipe-backend:latest registry.gitlab.com/fyipe-project/fyipe-backend:1.0.$CI_PIPELINE_IID
|
|
- sudo docker tag fyipe-project/fyipe-backend:latest registry.gitlab.com/fyipe-project/fyipe-backend:latest
|
|
- sudo docker push registry.gitlab.com/fyipe-project/fyipe-backend:1.0.$CI_PIPELINE_IID
|
|
- sudo docker push registry.gitlab.com/fyipe-project/fyipe-backend:latest
|
|
- sudo $HOME/google-cloud-sdk/bin/kubectl set image deployment/fyipe-backend fyipe-backend=registry.gitlab.com/fyipe-project/fyipe-backend:1.0.$CI_PIPELINE_IID
|
|
- cd ..
|
|
- cd kubernetes
|
|
- chmod +x ./ci/deployment-cleanup.sh
|
|
- ./ci/deployment-cleanup.sh
|
|
only:
|
|
refs:
|
|
- release
|
|
environment:
|
|
name: production
|