.gitlab-ci.yml 4.97 KB
Newer Older
1 2
variables:
    DOCKER_HOST: "tcp://docker-dind.gitlab:2375"
3
    AUTO_DEVOPS_BUILD_IMAGE_EXTRA_ARGS: "--network host"
4 5 6 7 8 9 10 11 12 13
    POSTGRES_ENABLED: "false"
    CODE_QUALITY_DISABLED: "true"
    CONTAINER_SCANNING_DISABLED: "true"
    DAST_DISABLED: "true"
    DEPENDENCY_SCANNING_DISABLED: "true"
    LICENSE_MANAGEMENT_DISABLED: "true"
    PERFORMANCE_DISABLED: "true"
    SAST_DISABLED: "true"
    TEST_DISABLED: "true"

Dominik Hebeler's avatar
Dominik Hebeler committed
14 15
include:
  - template: Jobs/Build.gitlab-ci.yml
Dominik Hebeler's avatar
Dominik Hebeler committed
16
  - template: Jobs/Deploy.gitlab-ci.yml
Dominik Hebeler's avatar
Dominik Hebeler committed
17

18 19
stages:
  - prepare
Dominik Hebeler's avatar
Dominik Hebeler committed
20
  - build
Dominik Hebeler's avatar
Dominik Hebeler committed
21 22 23 24 25
  - deploy  # dummy stage to follow the template guidelines
  - review
  - dast
  - staging
  - canary
26
  - development
Dominik Hebeler's avatar
Dominik Hebeler committed
27 28 29 30 31
  - production
  - incremental rollout 10%
  - incremental rollout 25%
  - incremental rollout 50%
  - incremental rollout 100%
Dominik Hebeler's avatar
Dominik Hebeler committed
32 33 34
  - performance
  - cleanup

35

Dominik Hebeler's avatar
Dominik Hebeler committed
36 37 38
build:
  services:

39
# Prepares the secret files that we cannot or don't want to share with public
Dominik Hebeler's avatar
Dominik Hebeler committed
40
prepare_secrets_master:
41 42 43 44 45 46
  stage: prepare
  image: alpine:latest
  script: 
    - cp $ENVFILE .env
    - cp $SUMAS config/sumas.json
    - cp $SUMASEN config/sumasEn.json
Dominik Hebeler's avatar
Dominik Hebeler committed
47 48 49 50 51 52
    - cp $BLACKLISTURL config/blacklistUrl.txt
    - cp $BLACKLISTDOMAINS config/blacklistDomains.txt
    - cp $ADBLACKLISTURL config/adBlacklistUrl.txt
    - cp $ADBLACKLISTDOMAINS config/adBlacklistDomains.txt
    - cp $SPAM config/spam.txt
    - cp $USERSSEEDER database/seeds/UsersSeeder.php
53
    - cp database/useragents.sqlite.example database/useragents.sqlite
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
    - sed -i 's/^APP_ENV=.*/APP_ENV=production/g' .env
    - sed -i 's/^REDIS_PASSWORD=.*/REDIS_PASSWORD=null/g' .env
  artifacts:
    paths:
      - .env
      - config/sumas.json
      - config/sumasEn.json
      - config/blacklistUrl.txt
      - config/blacklistDomains.txt
      - config/adBlacklistUrl.txt
      - config/adBlacklistDomains.txt
      - config/spam.txt
      - database/seeds/UsersSeeder.php
      - database/useragents.sqlite
  only:
    refs:
      - master    

Dominik Hebeler's avatar
Dominik Hebeler committed
72
prepare_secrets_development:
73 74 75 76 77 78 79 80 81 82 83 84 85 86
  stage: prepare
  image: alpine:latest
  script: 
    - cp $ENVFILE .env
    - cp $SUMAS config/sumas.json
    - cp $SUMASEN config/sumasEn.json
    - cp $BLACKLISTURL config/blacklistUrl.txt
    - cp $BLACKLISTDOMAINS config/blacklistDomains.txt
    - cp $ADBLACKLISTURL config/adBlacklistUrl.txt
    - cp $ADBLACKLISTDOMAINS config/adBlacklistDomains.txt
    - cp $SPAM config/spam.txt
    - cp $USERSSEEDER database/seeds/UsersSeeder.php
    - cp database/useragents.sqlite.example database/useragents.sqlite
    - sed -i 's/^APP_ENV=.*/APP_ENV=development/g' .env
87
    - sed -i 's/^REDIS_PASSWORD=.*/REDIS_PASSWORD=null/g' .env
88 89 90 91
  artifacts:
    paths:
      - .env
      - config/sumas.json
Dominik Hebeler's avatar
Dominik Hebeler committed
92 93 94 95 96 97 98
      - config/sumasEn.json
      - config/blacklistUrl.txt
      - config/blacklistDomains.txt
      - config/adBlacklistUrl.txt
      - config/adBlacklistDomains.txt
      - config/spam.txt
      - database/seeds/UsersSeeder.php
99
      - database/useragents.sqlite
Dominik Hebeler's avatar
Dominik Hebeler committed
100 101
  only:
    - branches
102
    - tags
103 104 105
  except:
    refs:
      - master
106 107 108 109 110 111 112 113 114 115 116 117

prepare_node:
  stage: prepare
  image: node:10
  before_script:
    - npm install
  script:
    - npm run prod
  artifacts:
    paths:
      - public/js/
      - public/css/
Dominik Hebeler's avatar
Dominik Hebeler committed
118
      - public/mix-manifest.json
119 120 121 122 123 124 125 126 127
  cache:
    # Cache per Branch
    key: "node-$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG"
    paths:
      - node_modules
  only:
    - branches
    - tags

Dominik Hebeler's avatar
Dominik Hebeler committed
128 129 130 131 132 133 134 135 136 137 138
prepare_composer:
  stage: prepare
  image: prooph/composer:7.3
  script:
    - composer install
  artifacts:
    paths:
      - vendor
  cache:
    key: "composer-$CI_JOB_STAGE-$CI_COMMIT_REF_SLUG"
    paths:
Dominik Hebeler's avatar
Dominik Hebeler committed
139 140 141 142
      - vendor

review:
  variables:
Dominik Hebeler's avatar
Dominik Hebeler committed
143
    HELM_UPGRADE_VALUES_FILE: .gitlab/review-apps-values.yaml
Dominik Hebeler's avatar
Dominik Hebeler committed
144
    ROLLOUT_RESOURCE_TYPE: deployment
145 146 147 148 149 150 151
  except:
    refs:
      - master
      - development
    variables:
      - $REVIEW_DISABLED

152 153 154 155 156 157 158
stop_review:
  except:
    refs:
      - master
      - development
    variables:
      - $REVIEW_DISABLED
159 160 161 162 163 164 165 166 167 168 169 170 171 172

.development: &development_template
  extends: .auto-deploy
  stage: development
  script:
    - auto-deploy check_kube_domain
    - auto-deploy download_chart
    - auto-deploy ensure_namespace
    - auto-deploy initialize_tiller
    - auto-deploy create_secret
    - auto-deploy deploy
    - auto-deploy delete canary
    - auto-deploy delete rollout
    - auto-deploy persist_environment_url
Dominik Hebeler's avatar
Dominik Hebeler committed
173
  variables:
174
    ADDITIONAL_HOSTS: "www.metager3.de"
Dominik Hebeler's avatar
Dominik Hebeler committed
175 176
    HELM_UPGRADE_VALUES_FILE: .gitlab/development-values.yaml
    ROLLOUT_RESOURCE_TYPE: deployment
177 178
  environment:
    name: development
Dominik Hebeler's avatar
Dominik Hebeler committed
179
    url: https://metager3.de
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
  artifacts:
    paths: [environment_url.txt]

development:
  <<: *development_template
  only:
    refs:
      - development
    kubernetes: active
  except:
    variables:
      - $STAGING_ENABLED
      - $CANARY_ENABLED
      - $INCREMENTAL_ROLLOUT_ENABLED
      - $INCREMENTAL_ROLLOUT_MODE

Dominik Hebeler's avatar
Dominik Hebeler committed
196

Dominik Hebeler's avatar
Dominik Hebeler committed
197 198
production:
  variables:
199
    ADDITIONAL_HOSTS: "www.metager.de,metager.org,www.metager.org,metager.es,www.metager.es,klassik.metager.org"
Dominik Hebeler's avatar
Dominik Hebeler committed
200
    HELM_UPGRADE_VALUES_FILE: .gitlab/production-values.yaml
Dominik Hebeler's avatar
Dominik Hebeler committed
201 202
    ROLLOUT_RESOURCE_TYPE: deployment
  environment:
203
    url: https://metager.de