video-iac/bitbucket-pipelines.yml

95 lines
3.6 KiB
YAML
Raw Normal View History

2021-11-16 12:59:43 +00:00
---
2021-07-16 15:15:34 +00:00
image: atlassian/default-image:2
definitions:
services:
docker:
memory: 3072
pipelines:
default:
- parallel:
- step:
2021-11-15 17:05:12 +00:00
name: Build images
2021-07-16 15:15:34 +00:00
script:
2021-11-15 15:42:36 +00:00
- docker build . --file docker/coturn/Dockerfile --tag coturn
- docker build . --file docker/coturn-dns/Dockerfile --tag coturn-dns
2021-07-16 15:15:34 +00:00
services:
- docker
caches:
- docker
- step:
name: Lint the Dockerfile
image: hadolint/hadolint:latest-debian
script:
2021-11-15 15:37:15 +00:00
- hadolint docker/coturn/Dockerfile
- hadolint docker/coturn-dns/Dockerfile
2021-07-16 15:15:34 +00:00
branches:
2021-07-16 15:24:04 +00:00
main:
2021-11-17 14:19:27 +00:00
- parallel:
- step:
name: Build images
script:
- docker build . --file docker/coturn/Dockerfile --tag coturn
- docker build . --file docker/coturn-dns/Dockerfile --tag coturn-dns
- docker save coturn --output "coturn.tar"
- docker save coturn-dns --output "coturn-dns.tar"
services:
- docker
caches:
- docker
artifacts:
- "*.tar"
2021-11-17 14:20:55 +00:00
- step:
name: Deploy terraform
2021-11-17 14:23:13 +00:00
image: hashicorp/terraform:latest
2021-11-17 14:20:55 +00:00
script:
- cd terraform/
- terraform init
- terraform plan
2021-11-17 14:52:49 +00:00
- terraform apply -input=false -auto-approve
2021-11-17 14:33:39 +00:00
- step:
2021-11-17 14:39:58 +00:00
name: Deploy K8s apps (staging)
2021-11-17 14:33:39 +00:00
script:
2021-11-17 15:26:01 +00:00
- pipe: atlassian/kubectl-run:3.1.2
2021-11-17 14:33:39 +00:00
variables:
KUBE_CONFIG: $KUBE_CONFIG_STG
KUBECTL_COMMAND: '-n argocd apply -k k8s/argocd/overlays/staging'
2021-07-16 15:15:34 +00:00
- step:
2021-11-15 17:05:12 +00:00
name: Push images
2021-07-16 15:15:34 +00:00
image: google/cloud-sdk:alpine
script:
# Authenticating with the service account key file
- echo $GCLOUD_API_KEYFILE | base64 -d > ./gcloud-api-key.json
- gcloud auth activate-service-account --key-file gcloud-api-key.json
- gcloud config set project $GCLOUD_PROJECT
2021-11-16 12:59:43 +00:00
- cat ./gcloud-api-key.json | docker login -u _json_key --password-stdin https://gcr.io
# Push Docker images
- VERSION="latest"
2021-11-15 16:55:04 +00:00
- docker load --input "coturn.tar"
- docker load --input "coturn-dns.tar"
2021-11-15 15:42:36 +00:00
- docker tag "coturn" "gcr.io/${GCLOUD_PROJECT}/coturn:${VERSION}"
- docker tag "coturn-dns" "gcr.io/${GCLOUD_PROJECT}/coturn-dns:${VERSION}"
2021-11-15 15:37:15 +00:00
- docker push "gcr.io/${GCLOUD_PROJECT}/coturn:${VERSION}"
2021-08-10 17:36:34 +00:00
- docker push "gcr.io/${GCLOUD_PROJECT}/coturn-dns:${VERSION}"
2021-07-16 15:15:34 +00:00
services:
2021-11-16 12:59:43 +00:00
- docker
- step:
2021-11-17 14:38:49 +00:00
name: Deploy coturn/coturn-dns to staging
2021-11-16 16:03:23 +00:00
deployment: staging
2021-11-16 12:59:43 +00:00
script:
- pipe: atlassian/kubectl-run:1.1.2
variables:
KUBE_CONFIG: $KUBE_CONFIG_STG
2021-11-16 15:51:18 +00:00
KUBECTL_COMMAND: '-n coturn rollout restart deployment/coturn'
2021-11-16 12:59:43 +00:00
- pipe: atlassian/kubectl-run:1.1.2
variables:
KUBE_CONFIG: $KUBE_CONFIG_STG
2021-11-16 13:52:30 +00:00
KUBECTL_COMMAND: '-n coturn rollout status -w deployment/coturn'
2021-11-16 12:59:43 +00:00
- pipe: atlassian/kubectl-run:1.1.2
variables:
KUBE_CONFIG: $KUBE_CONFIG_STG
2021-11-16 13:52:30 +00:00
KUBECTL_COMMAND: '-n coturn-dns rollout restart deployment/coturn-dns'
2021-11-16 12:59:43 +00:00
- pipe: atlassian/kubectl-run:1.1.2
variables:
KUBE_CONFIG: $KUBE_CONFIG_STG
2021-11-16 13:52:30 +00:00
KUBECTL_COMMAND: '-n coturn-dns rollout status -w deployment/coturn-dns'