Skip to content
Snippets Groups Projects
Commit 343f8d07 authored by Christian Boettcher's avatar Christian Boettcher
Browse files

copy the deployment rules from airflow

parent 2ab1b9c9
Branches
Tags
No related merge requests found
Pipeline #132177 passed
...@@ -53,11 +53,8 @@ test: ...@@ -53,11 +53,8 @@ test:
light-deploy-testing: light-deploy-testing:
stage: deploy stage: deploy
# only run when master is updated, unless the pipeline was triggered via the web UI # only run when master is updated, unless the pipeline was triggered via the web UI
only: rules:
- master - if: ($CI_COMMIT_BRANCH == "master" && $MANUAL_FULL_DEPLOY !~ /true/ )
except:
- tags
- web
<<: *ssh_setup <<: *ssh_setup
environment: Testing environment: Testing
script: script:
...@@ -67,10 +64,8 @@ light-deploy-testing: ...@@ -67,10 +64,8 @@ light-deploy-testing:
light-deploy-production: light-deploy-production:
stage: deploy stage: deploy
# only run when stable tag is updated, unless the pipeline was triggered via the web UI # only run when stable tag is updated, unless the pipeline was triggered via the web UI
only: rules:
- tags - if: ($CI_COMMIT_TAG =~ /stable/ && $MANUAL_FULL_DEPLOY !~ /true/)
except:
- web
tags: [stable] tags: [stable]
<<: *ssh_setup <<: *ssh_setup
environment: Production environment: Production
...@@ -81,9 +76,8 @@ light-deploy-production: ...@@ -81,9 +76,8 @@ light-deploy-production:
full-deploy-production: full-deploy-production:
stage: deploy stage: deploy
# only run when stable tag is assigned and the pipeline is triggered in the web UI # only run when stable tag is assigned and the pipeline is triggered in the web UI
only: rules:
- web - if: ($CI_COMMIT_TAG =~ /stable/ && $MANUAL_FULL_DEPLOY == "true")
- tags
<<: *ssh_setup <<: *ssh_setup
environment: Production environment: Production
script: script:
...@@ -108,9 +102,8 @@ full-deploy-production: ...@@ -108,9 +102,8 @@ full-deploy-production:
full-deploy-testing: full-deploy-testing:
stage: deploy stage: deploy
# only run when master is updated and the pipeline is triggered in the web UI # only run when master is updated and the pipeline is triggered in the web UI
only: rules:
variables: - if: ($CI_COMMIT_BRANCH == "master" && $MANUAL_FULL_DEPLOY == "true")
- ($CI_PIPELINE_SOURCE == "web" && $CI_COMMIT_REF_NAME == "master")
<<: *ssh_setup <<: *ssh_setup
environment: Testing environment: Testing
script: script:
...@@ -136,8 +129,8 @@ cleanup-failed-full-deployment: ...@@ -136,8 +129,8 @@ cleanup-failed-full-deployment:
# this does not guarantee a successful rollback, but unless the old instance was faulty, this should work # this does not guarantee a successful rollback, but unless the old instance was faulty, this should work
stage: cleanup stage: cleanup
when: on_failure when: on_failure
only: rules:
- web - if: $MANUAL_FULL_DEPLOY == "true"
<<: *ssh_setup <<: *ssh_setup
script: script:
- echo "This is the cleanup for the full-redeployment of the testing or production servers" - echo "This is the cleanup for the full-redeployment of the testing or production servers"
...@@ -172,8 +165,8 @@ cleanup-successful-full-deployment: ...@@ -172,8 +165,8 @@ cleanup-successful-full-deployment:
# check if there is an old prod or test instance, and delete it if present # check if there is an old prod or test instance, and delete it if present
stage: cleanup stage: cleanup
when: on_success when: on_success
only: rules:
- web - if: $MANUAL_FULL_DEPLOY == "true"
<<: *ssh_setup <<: *ssh_setup
script: script:
- echo "This is the cleanup for the full-redeployment of the testing or production servers" - echo "This is the cleanup for the full-redeployment of the testing or production servers"
...@@ -186,11 +179,8 @@ cleanup-failed-light-test-deployment: ...@@ -186,11 +179,8 @@ cleanup-failed-light-test-deployment:
# if there is a failure with the light deployments, this tries to git checkout an earlier version and rollback to that. # if there is a failure with the light deployments, this tries to git checkout an earlier version and rollback to that.
stage: cleanup stage: cleanup
when: on_failure when: on_failure
only: rules:
- master - if: ($CI_COMMIT_BRANCH == "master" && $MANUAL_FULL_DEPLOY !~ /true/ )
except:
- tags
- web
<<: *ssh_setup <<: *ssh_setup
script: script:
- echo "This is the cleanup for the light-redeployment of the testing servers" - echo "This is the cleanup for the light-redeployment of the testing servers"
...@@ -205,10 +195,8 @@ cleanup-failed-light-production-deployment: ...@@ -205,10 +195,8 @@ cleanup-failed-light-production-deployment:
# if there is a failure with the light deployments, this tries to git checkout an earlier version and rollback to that. # if there is a failure with the light deployments, this tries to git checkout an earlier version and rollback to that.
stage: cleanup stage: cleanup
when: on_failure when: on_failure
only: rules:
- tags - if: ($CI_COMMIT_TAG =~ /stable/ && $MANUAL_FULL_DEPLOY !~ /true/)
except:
- web
tags: [stable] tags: [stable]
<<: *ssh_setup <<: *ssh_setup
script: script:
...@@ -222,10 +210,9 @@ cleanup-failed-light-production-deployment: ...@@ -222,10 +210,9 @@ cleanup-failed-light-production-deployment:
test-testing: test-testing:
cache: {} cache: {}
stage: test-deployment stage: test-deployment
only: when: on_failure
- master rules:
except: - if: $CI_COMMIT_BRANCH == "master"
- tags
script: script:
- apt update && apt -y install curl - apt update && apt -y install curl
- echo "For now, this will be a basic health check i.e. GET / and check for 2xx code." - echo "For now, this will be a basic health check i.e. GET / and check for 2xx code."
...@@ -235,8 +222,8 @@ test-testing: ...@@ -235,8 +222,8 @@ test-testing:
test-production: test-production:
cache: {} cache: {}
stage: test-deployment stage: test-deployment
only: rules:
- tags - if: $CI_COMMIT_TAG =~ /stable/
tags: [stable] tags: [stable]
script: script:
- apt update && apt -y install curl - apt update && apt -y install curl
......
...@@ -158,3 +158,11 @@ docker rm <container name> ...@@ -158,3 +158,11 @@ docker rm <container name>
``` ```
For more information about docker, please see the [docker docs](https://docs.docker.com) For more information about docker, please see the [docker docs](https://docs.docker.com)
## CI/CD
The gitlab repository is set up to automatically build the datacat image and deploy to the production and testing environment. The pipeline and jobs for this are defined in the [.gitlab-ci.yml](.gitlab-ci.yml) file.
In general, pushes to the master branch update the testing deployment, and tags containing "stable" update the production deployment.
To avoid unneeded downtime, the VMs hosting the deployments are usuallly not re-created, and instead only the updated docker image, as well as updated config is uploaded to the VM. After this, the docker containers are restarted.
If a "full-deployment" is required (i.e. the VMs shuld be newly created), the pipeline has to be started with a variable ```MANUAL_FULL_DEPLOY=true```. This can be done while starting the pipeline via the web interface.
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment