Commit 02ddf983 authored by Mark Harding's avatar Mark Harding

(feat): new ci flow for staging, canary and production

No related merge requests found
Pipeline #73941055 failed with stages
in 38 minutes and 23 seconds
......@@ -7,7 +7,16 @@ stages:
- test
- build
- prepare
- deploy
- review
- deploy:staging
- deploy:canary
- deploy:production
cache:
key: $CI_BUILD_REF_SLUG
paths:
- node_modules
policy: pull
test:
image: circleci/node:8-browsers
......@@ -15,6 +24,11 @@ test:
script:
- npm install # Should be cached...
- npm run test -- --no-watch --no-progress --browsers=ChromeHeadlessCI
cache:
key: $CI_BUILD_REF_SLUG
paths:
- node_modules
policy: pull-push
build:review:
stage: build
......@@ -22,6 +36,7 @@ build:review:
- npm install # TODO: Why is this needed?
- npm run postinstall
- npm install -g gulp-cli
- npm rebuild node-sass
- gulp build.sass && gulp build.sass ##weird build needs to be run twice for now
- sh build/base-locale.sh dist
artifacts:
......@@ -39,6 +54,7 @@ build:production:en:
- npm install # TODO: Why is this needed?
- npm run postinstall
- npm install -g gulp-cli
- npm rebuild node-sass
- gulp build.sass --deploy-url=https://cdn-assets.minds.com/front/dist/en && gulp build.sass --deploy-url=https://cdn-assets.minds.com/front/dist/en ##weird build needs to be run twice for now
- sh build/base-locale.sh dist https://cdn-assets.minds.com/front/dist
artifacts:
......@@ -56,6 +72,7 @@ build:production:i18n:
- npm install # TODO: Why is this needed?
- npm run postinstall
- npm install -g gulp-cli
- npm rebuild node-sass
- gulp build.sass --deploy-url=https://cdn-assets.minds.com/front/dist/en && gulp build.sass --deploy-url=https://cdn-assets.minds.com/front/dist/en ##weird build needs to be run twice for now
- sh build/i18n-locales-all.sh dist https://cdn-assets.minds.com/front/dist
artifacts:
......@@ -67,7 +84,7 @@ build:production:i18n:
- master
- test/gitlab-ci
prepare:
prepare:review:
stage: prepare
image: minds/ci:latest
script:
......@@ -81,8 +98,23 @@ prepare:
- master
- test/gitlab-ci
deploy:review:
stage: deploy
prepare:production:
stage: prepare
image: minds/ci:latest
script:
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- docker build -t $CI_REGISTRY_IMAGE/front-init:$CI_BUILD_REF -f containers/front-init/Dockerfile dist/.
- docker push $CI_REGISTRY_IMAGE/front-init:$CI_BUILD_REF
only:
refs:
- production
- test/gitlab-ci
dependencies:
- build:production:en
- build:production:i18n
review:start:
stage: review
image: minds/helm-eks:latest
script:
- aws eks update-kubeconfig --name=sandbox
......@@ -100,14 +132,14 @@ deploy:review:
environment:
name: review/$CI_COMMIT_REF_NAME
url: https://$CI_BUILD_REF_SLUG.$KUBE_INGRESS_BASE_DOMAIN
on_stop: deploy:review:stop
on_stop: review:stop
except:
refs:
- master
- test/gitlab-ci
deploy:review:stop:
stage: deploy
review:stop:
stage: review
image: minds/helm-eks:latest
script:
- aws eks update-kubeconfig --name=sandbox
......@@ -124,13 +156,73 @@ deploy:review:stop:
- master
- test/gitlab-ci
staging:fpm:
stage: deploy:staging
image: minds/ci:latest
script:
- IMAGE_LABEL="staging"
## Sync assets with CDN
- aws s3 sync dist $S3_REPOSITORY_URL
- $(aws ecr get-login --no-include-email --region us-east-1)
## Update docker front-init container
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- docker pull $CI_REGISTRY_IMAGE/front-init:$CI_BUILD_REF
- docker tag $CI_REGISTRY_IMAGE/front-init:$CI_BUILD_REF $ECR_REPOSITORY_URL:$IMAGE_LABEL
- docker push $ECR_REPOSITORY_URL:$IMAGE_LABEL
## Deploy the new container in rolling restart
- aws ecs update-service --service=$ECS_APP_STAGING_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER
only:
refs:
- master
- test/gitlab-ci
dependencies:
- build:production:en
- build:production:i18n
environment:
name: staging
url: https://www.minds.com/?canary=1 # requires canary cookie
deploy:canary:
stage: deploy:canary
image: minds/ci:latest
script:
- IMAGE_LABEL="canary"
## Sync assets with CDN
- aws s3 sync dist $S3_REPOSITORY_URL
- $(aws ecr get-login --no-include-email --region us-east-1)
## Update docker front-init container
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- docker pull $CI_REGISTRY_IMAGE/front-init:$CI_BUILD_REF
- docker tag $CI_REGISTRY_IMAGE/front-init:$CI_BUILD_REF $ECR_REPOSITORY_URL:$IMAGE_LABEL
- docker push $ECR_REPOSITORY_URL:$IMAGE_LABEL
## Deploy the new container in rolling restart
- aws ecs update-service --service=$ECS_APP_CANARY_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER
only:
refs:
- master
- test/gitlab-ci
dependencies:
- build:production:en
- build:production:i18n
environment:
name: canary
url: https://www.minds.com/?canary=1 # requires canary cookie
when: manual
allow_failure: false # prevents auto deploy to full production
deploy:production:
stage: deploy
stage: deploy:production
image: minds/ci:latest
script:
- aws s3 sync dist $REPOSITORY_URL
- aws ecs update-service --service=$SERVICE --force-new-deployment --region us-east-1 --cluster=$CLUSTER
- IMAGE_LABEL="production"
- $(aws ecr get-login --no-include-email --region us-east-1)
## Update docker front-init container
- docker login -u gitlab-ci-token -p ${CI_BUILD_TOKEN} ${CI_REGISTRY}
- docker pull $CI_REGISTRY_IMAGE/front-init:$CI_BUILD_REF
- docker tag $CI_REGISTRY_IMAGE/front-init:$CI_BUILD_REF $ECR_REPOSITORY_URL:$IMAGE_LABEL
- docker push $ECR_REPOSITORY_URL:$IMAGE_LABEL
## Deploy the new container in rolling restart
- aws ecs update-service --service=$ECS_APP_PRODUCTION_SERVICE --force-new-deployment --region us-east-1 --cluster=$ECS_CLUSTER
only:
refs:
- master
......@@ -140,3 +232,6 @@ deploy:production:
- build:production:i18n
environment:
name: production
url: https://www.minds.com
when: delayed
start_in: 2 hours # reduce? can always be deployed manually earlier too
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment