Changeset - 97757028d2ab
[Not reviewed]
1 0 1
Ben Stevens - 5 years ago 2019-06-17 12:55:39
benjamin.stevens.au@gmail.com
Addition of 'release/' branch logic
1 file changed with 32 insertions and 0 deletions:
0 comments (0 inline, 0 general)
.gitlab-ci.yml
Show inline comments
 
file renamed from .gitlab-ci-disabled.yml to .gitlab-ci.yml
 
variables:
 
  CONTAINER_IMAGE_2019: "asia.gcr.io/linuxconfsydney/symposion_app_2019"
 
  CONTAINER_IMAGE_FROM_DEV: "asia.gcr.io/linuxconfsydney/symposion_app_${CI_COMMIT_REF_NAME#dev/}"
 
  CONTAINER_IMAGE_FROM_RELEASE: "asia.gcr.io/linuxconfsydney/symposion_app_${CI_COMMIT_REF_NAME#release/}"
 
  NAMESPACE_FROM_RELEASE: "lca${CI_COMMIT_REF_NAME#release/}-prod"
 
  DOCKER_DRIVER: overlay2
 

	
 
build_image:
 
  image: docker:git
 
  stage: build
 
  services:
 
  - docker:dind
 
  script:
 
    - docker build -f docker/Dockerfile -t asia.gcr.io/linuxconfsydney/symposion_app:$CI_COMMIT_SHA .
 
    - docker build --build-arg CI_COMMIT_SHA=$CI_COMMIT_SHA -f docker/Dockerfile.dev -t asia.gcr.io/linuxconfsydney/symposion_app_dev:$CI_COMMIT_SHA .
 
    - docker login -u _json_key -p "$GOOGLE_KEY" https://asia.gcr.io
 
    - docker push asia.gcr.io/linuxconfsydney/symposion_app:$CI_COMMIT_SHA
 
    - docker push asia.gcr.io/linuxconfsydney/symposion_app_dev:$CI_COMMIT_SHA
 
    - docker tag asia.gcr.io/linuxconfsydney/symposion_app:$CI_COMMIT_SHA asia.gcr.io/linuxconfsydney/symposion_app:latest
 
    - docker tag asia.gcr.io/linuxconfsydney/symposion_app_dev:$CI_COMMIT_SHA asia.gcr.io/linuxconfsydney/symposion_app_dev:latest
 
    - docker push asia.gcr.io/linuxconfsydney/symposion_app:latest
 
    - docker push asia.gcr.io/linuxconfsydney/symposion_app_dev:latest
 
  only:
 
    - master
 

	
 
build_release_image:
 
  image: docker:git
 
  stage: build
 
  services:
 
  - docker:dind
 
  script:
 
  - docker build -f docker/Dockerfile -t ${CONTAINER_IMAGE_FROM_RELEASE}:latest -t ${CONTAINER_IMAGE_FROM_RELEASE}:$CI_COMMIT_SHA .
 
  - docker login -u _json_key -p "$GOOGLE_KEY" https://asia.gcr.io
 
  - docker push ${CONTAINER_IMAGE_FROM_RELEASE}:$CI_COMMIT_SHA
 
  - docker push ${CONTAINER_IMAGE_FROM_RELEASE}:latest
 
  only:
 
    - /^release\/.*$/
 

	
 
k8s-prod-deploy:
 
  image: google/cloud-sdk
 
  stage: deploy
 
  script:
 
  - echo "$GOOGLE_KEY" > key.json
 
  - gcloud auth activate-service-account --key-file key.json
 
  - gcloud config set compute/zone australia-southeast1-b
 
  - gcloud config set project linuxconfsydney
 
  - gcloud config set container/use_client_certificate True
 
  - gcloud container clusters get-credentials lca02
 
  - kubectl --namespace=rego-prod set image deployment/symposion-app symposion-app=asia.gcr.io/linuxconfsydney/symposion_app:$CI_COMMIT_SHA
 
  when: manual
...
 
@@ -63,24 +79,40 @@ build_2019_image:
 
    - docker pull "${CONTAINER_IMAGE_2019}":latest || true
 
    - docker build --cache-from "${CONTAINER_IMAGE_2019}":latest -f docker/Dockerfile -t "${CONTAINER_IMAGE_2019}":$CI_COMMIT_SHA .
 
    - docker push "${CONTAINER_IMAGE_2019}":$CI_COMMIT_SHA
 
    - docker build --build-arg CI_COMMIT_SHA=$CI_COMMIT_SHA -f docker/Dockerfile.dev -t "${CONTAINER_IMAGE_2019}"_dev:$CI_COMMIT_SHA .
 
    - docker push "${CONTAINER_IMAGE_2019}"_dev:$CI_COMMIT_SHA
 
    - docker tag "${CONTAINER_IMAGE_2019}"_dev:$CI_COMMIT_SHA "${CONTAINER_IMAGE_2019}"_dev:$CI_COMMIT_REF_SLUG
 
    - docker push "${CONTAINER_IMAGE_2019}"_dev:$CI_COMMIT_REF_SLUG
 
  except:
 
    - "2019"
 
    - "master"
 

	
 

	
 
deploy-release:
 
  image: google/cloud-sdk
 
  stage: deploy
 
  script:
 
  - echo "${CA_CERT}" > cert.crt
 
  - kubectl config set-cluster cluster --server="${KUBE_SERVER}" --embed-certs=true --certificate-authority=cert.crt
 
  - kubectl config set-context cluster --cluster=cluster --namespace=${NAMESPACE_FROM_RELEASE} --user=gitlab-ci
 
  - kubectl config use-context cluster
 
  - kubectl --token "${GL_KUBE_TOKEN}" set image deployment/symposion-app symposion-app="${CONTAINER_IMAGE_FROM_RELEASE}":$CI_COMMIT_SHA
 
  only:
 
  - /^release\/.*$/
 
  environment:
 
    name: 2020/prod
 
    url: https://2020.linux.conf.au
 

	
 

	
 
2019-prod-deploy:
 
  image: google/cloud-sdk
 
  stage: deploy
 
  script:
 
  - echo "${CA_CERT}" > cert.crt
 
  - kubectl config set-cluster cluster --server="${KUBE_SERVER}" --embed-certs=true --certificate-authority=cert.crt
 
  - kubectl config set-context cluster --cluster=cluster --namespace=lca2019-prod --user=gitlab-ci
 
  - kubectl config use-context cluster
 
  - kubectl --token "${GL_KUBE_TOKEN}" set image deployment/symposion-app symposion-app="${CONTAINER_IMAGE_2019}":$CI_COMMIT_SHA
 
  only:
 
  - "2019"
 
  when: manual
0 comments (0 inline, 0 general)