зеркало из https://github.com/mozilla/mozillians.git
42 строки
2.0 KiB
YAML
42 строки
2.0 KiB
YAML
version: 0.2
|
|
|
|
env:
|
|
variables:
|
|
IMAGE_NAME: dino-park-mozillians
|
|
DOCKER_REGISTRY: 320464205386.dkr.ecr.us-west-2.amazonaws.com
|
|
|
|
phases:
|
|
install:
|
|
commands:
|
|
- apt update && apt install -y apt-transport-https curl
|
|
- curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
|
|
- echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | tee -a /etc/apt/sources.list.d/kubernetes.list
|
|
- apt update && apt install -y kubectl
|
|
- curl -O https://storage.googleapis.com/kubernetes-helm/helm-v2.11.0-linux-amd64.tar.gz
|
|
- tar zxf helm-v2.11.0-linux-amd64.tar.gz
|
|
- mv linux-amd64/helm /usr/local/bin/
|
|
- curl -O https://amazon-eks.s3-us-west-2.amazonaws.com/1.10.3/2018-07-26/bin/linux/amd64/aws-iam-authenticator
|
|
- chmod +x aws-iam-authenticator
|
|
- mv aws-iam-authenticator /usr/local/bin/
|
|
- apt update && apt install -y python3-pip
|
|
- pip3 install awscli
|
|
- echo "Configuring kubectl"
|
|
pre_build:
|
|
commands:
|
|
- export COMMIT_SHA=$CODEBUILD_RESOLVED_SOURCE_VERSION
|
|
- export DEPLOY_ENV=$(echo $CODEBUILD_WEBHOOK_TRIGGER | sed -e 's/tag\/.*-\(.*\)/\1/' | sed -e 's/branch\/master/dev/')
|
|
- export MASTER=$(if [ "$CODEBUILD_WEBHOOK_TRIGGER" = "branch/master" ]; then echo 1; fi)
|
|
- echo "running for ${COMMIT_SHA} in ${DEPLOY_ENV}"
|
|
- aws eks update-kubeconfig --name $CLUSTER_NAME
|
|
- aws ecr get-login --region us-west-2 --no-include-email | bash
|
|
build:
|
|
commands:
|
|
- docker build -t $IMAGE_NAME:$COMMIT_SHA -f docker/prod .
|
|
- docker tag $IMAGE_NAME:$COMMIT_SHA $DOCKER_REGISTRY/$IMAGE_NAME:$COMMIT_SHA
|
|
- docker push $DOCKER_REGISTRY/$IMAGE_NAME:$COMMIT_SHA
|
|
post_build:
|
|
commands:
|
|
- echo "Finding appropriate deployment environment"
|
|
- echo "Environment is ${DEPLOY_ENV}"
|
|
- helm template -f k8s/values.yaml -f k8s/values/$DEPLOY_ENV.yaml --set docker_registry=$DOCKER_REGISTRY,rev=$COMMIT_SHA k8s/ | kubectl --token $DEPLOY_TOKEN apply -f -
|