2026-01-11 21:35:30 +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:
|
2025-07-20 22:21:40 +00:00
|
|
|
name: Deploy K8s apps (production)
|
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:
|
2025-07-20 22:21:40 +00:00
|
|
|
KUBE_CONFIG: $KUBE_CONFIG_PRD
|
2026-02-06 12:19:46 +00:00
|
|
|
KUBECTL_COMMAND: '-n argocd apply -k k8s/argocd/overlays/production --server-side --force-conflicts'
|
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"
|
2025-04-06 22:57:45 +00:00
|
|
|
- docker tag "coturn" "gcr.io/${GCLOUD_PROJECT}/coturn:${VERSION-staging}"
|
|
|
|
|
- docker tag "coturn-dns" "gcr.io/${GCLOUD_PROJECT}/coturn-dns:${VERSION-staging}"
|
|
|
|
|
- docker push "gcr.io/${GCLOUD_PROJECT}/coturn:${VERSION-staging}"
|
|
|
|
|
- docker push "gcr.io/${GCLOUD_PROJECT}/coturn-dns:${VERSION-staging}"
|
2021-07-16 15:15:34 +00:00
|
|
|
services:
|
2021-11-16 12:59:43 +00:00
|
|
|
- docker
|
2021-11-18 19:25:59 +00:00
|
|
|
- step:
|
2026-01-11 21:35:30 +00:00
|
|
|
name: Deploy, Verify and Test Production
|
2021-11-18 19:26:56 +00:00
|
|
|
deployment: production
|
2026-01-11 21:35:30 +00:00
|
|
|
image: node:22
|
2021-11-18 19:25:59 +00:00
|
|
|
script:
|
2026-01-11 21:35:30 +00:00
|
|
|
- apt-get update && apt-get install -y curl jq git
|
2026-02-07 04:13:25 +00:00
|
|
|
- curl -LO "https://dl.k8s.io/release/v1.28.3/bin/linux/amd64/kubectl"
|
2026-01-11 21:35:30 +00:00
|
|
|
- install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
|
|
|
|
|
- echo $KUBE_CONFIG_PRD | base64 -d > kubeconfig
|
|
|
|
|
- export KUBECONFIG=$(pwd)/kubeconfig
|
|
|
|
|
- kubectl -n coturn rollout restart deployment/coturn
|
|
|
|
|
- kubectl -n coturn rollout status -w deployment/coturn
|
|
|
|
|
- kubectl -n coturn-dns rollout restart deployment/coturn-dns
|
|
|
|
|
- kubectl -n coturn-dns rollout status -w deployment/coturn-dns
|
|
|
|
|
- chmod +x scripts/verify-deployment.sh
|
|
|
|
|
- ./scripts/verify-deployment.sh $BITBUCKET_COMMIT production
|
|
|
|
|
- npx playwright install-deps
|
|
|
|
|
- git clone --depth 1 git@bitbucket.org:jamkazam/video-e2e.git
|
|
|
|
|
- cd video-e2e
|
|
|
|
|
- npm install
|
|
|
|
|
- npx playwright install chromium
|
|
|
|
|
- ./bin/production-test
|
|
|
|
|
after-script:
|
|
|
|
|
- |
|
|
|
|
|
if [ $BITBUCKET_EXIT_CODE -ne 0 ]; then
|
|
|
|
|
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"🚨 Pipeline Failed: Production verification/tests failed for commit $BITBUCKET_COMMIT. <https://bitbucket.org/$BITBUCKET_REPO_FULL_NAME/pipelines/results/$BITBUCKET_BUILD_NUMBER|View Log>\"}" https://hooks.slack.com/services/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
|
|
|
|
|
fi
|
2025-04-06 22:57:45 +00:00
|
|
|
develop:
|
|
|
|
|
- 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"
|
|
|
|
|
- step:
|
|
|
|
|
name: Deploy terraform
|
|
|
|
|
image: hashicorp/terraform:latest
|
|
|
|
|
script:
|
|
|
|
|
- cd terraform/
|
|
|
|
|
- terraform init
|
|
|
|
|
- terraform plan
|
|
|
|
|
- terraform apply -input=false -auto-approve
|
|
|
|
|
- step:
|
|
|
|
|
name: Deploy K8s apps (staging)
|
|
|
|
|
script:
|
2025-07-20 02:18:44 +00:00
|
|
|
# Set a default branch for local testing or safety if BITBUCKET_BRANCH is not always present
|
|
|
|
|
- export BITBUCKET_BRANCH=${BITBUCKET_BRANCH:-notarealbranch}
|
|
|
|
|
|
|
|
|
|
# Template argocd/base/applications.yaml in place for the current pipeline run
|
|
|
|
|
- envsubst < k8s/argocd/base/applications.yaml > k8s/argocd/base/applications.yaml.tmp
|
|
|
|
|
- mv k8s/argocd/base/applications.yaml.tmp k8s/argocd/base/applications.yaml
|
|
|
|
|
|
|
|
|
|
# Now run kubectl apply -k. Kustomize will pick up the modified base file.
|
2025-04-06 22:57:45 +00:00
|
|
|
- pipe: atlassian/kubectl-run:3.1.2
|
|
|
|
|
variables:
|
|
|
|
|
KUBE_CONFIG: $KUBE_CONFIG_STG
|
2026-02-06 12:19:46 +00:00
|
|
|
KUBECTL_COMMAND: '-n argocd apply -k k8s/argocd/overlays/staging --server-side --force-conflicts'
|
2025-04-06 22:57:45 +00:00
|
|
|
- step:
|
|
|
|
|
name: Push images
|
|
|
|
|
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
|
|
|
|
|
- cat ./gcloud-api-key.json | docker login -u _json_key --password-stdin https://gcr.io
|
|
|
|
|
# Push Docker images
|
|
|
|
|
- VERSION="latest"
|
|
|
|
|
- docker load --input "coturn.tar"
|
|
|
|
|
- docker load --input "coturn-dns.tar"
|
|
|
|
|
- docker tag "coturn" "gcr.io/${GCLOUD_PROJECT}/coturn:${VERSION}"
|
|
|
|
|
- docker tag "coturn-dns" "gcr.io/${GCLOUD_PROJECT}/coturn-dns:${VERSION}"
|
|
|
|
|
- docker push "gcr.io/${GCLOUD_PROJECT}/coturn:${VERSION}"
|
|
|
|
|
- docker push "gcr.io/${GCLOUD_PROJECT}/coturn-dns:${VERSION}"
|
|
|
|
|
services:
|
|
|
|
|
- docker
|
|
|
|
|
- step:
|
2026-01-11 20:00:07 +00:00
|
|
|
name: Deploy, Verify and Test Staging
|
2026-01-11 19:11:01 +00:00
|
|
|
deployment: staging
|
|
|
|
|
image: node:22
|
|
|
|
|
script:
|
|
|
|
|
- apt-get update && apt-get install -y curl jq git
|
2026-02-07 04:13:25 +00:00
|
|
|
- curl -LO "https://dl.k8s.io/release/v1.28.3/bin/linux/amd64/kubectl"
|
2026-01-11 19:11:01 +00:00
|
|
|
- install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
|
|
|
|
|
- echo $KUBE_CONFIG_STG | base64 -d > kubeconfig
|
|
|
|
|
- export KUBECONFIG=$(pwd)/kubeconfig
|
2026-01-11 20:00:07 +00:00
|
|
|
- kubectl -n coturn rollout restart deployment/coturn
|
|
|
|
|
- kubectl -n coturn rollout status -w deployment/coturn
|
|
|
|
|
- kubectl -n coturn-dns rollout restart deployment/coturn-dns
|
|
|
|
|
- kubectl -n coturn-dns rollout status -w deployment/coturn-dns
|
2026-01-11 19:11:01 +00:00
|
|
|
- chmod +x scripts/verify-deployment.sh
|
|
|
|
|
- ./scripts/verify-deployment.sh $BITBUCKET_COMMIT staging
|
2026-01-11 20:00:07 +00:00
|
|
|
- npx playwright install-deps
|
2026-01-11 19:11:01 +00:00
|
|
|
- git clone --depth 1 git@bitbucket.org:jamkazam/video-e2e.git
|
|
|
|
|
- cd video-e2e
|
|
|
|
|
- npm install
|
|
|
|
|
- npx playwright install chromium
|
|
|
|
|
- ./bin/staging-test
|
|
|
|
|
after-script:
|
2026-01-11 20:00:07 +00:00
|
|
|
- |
|
2026-01-11 19:18:59 +00:00
|
|
|
if [ $BITBUCKET_EXIT_CODE -ne 0 ]; then
|
2026-01-11 19:11:01 +00:00
|
|
|
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"🚨 Pipeline Failed: Staging verification/tests failed for commit $BITBUCKET_COMMIT. <https://bitbucket.org/$BITBUCKET_REPO_FULL_NAME/pipelines/results/$BITBUCKET_BUILD_NUMBER|View Log>\"}" https://hooks.slack.com/services/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
|
|
|
|
|
fi
|
2026-01-11 21:35:30 +00:00
|
|
|
- step:
|
|
|
|
|
name: Promote to Production
|
|
|
|
|
script:
|
|
|
|
|
- git config --global user.email "ci-bot@jamkazam.com"
|
|
|
|
|
- git config --global user.name "CI Bot"
|
|
|
|
|
- git fetch origin main:main
|
|
|
|
|
- git checkout main
|
|
|
|
|
- git merge $BITBUCKET_COMMIT
|
|
|
|
|
- git push origin main
|
2026-01-07 02:45:02 +00:00
|
|
|
custom:
|
|
|
|
|
build-and-push-coturn-dns:
|
|
|
|
|
- variables:
|
|
|
|
|
- name: VERSION
|
|
|
|
|
default: "1.0.10"
|
|
|
|
|
- step:
|
|
|
|
|
name: Build and Push coturn-dns
|
|
|
|
|
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
|
|
|
|
|
- cat ./gcloud-api-key.json | docker login -u _json_key --password-stdin https://gcr.io
|
|
|
|
|
# Build and Push Docker image
|
|
|
|
|
- docker build . --file docker/coturn-dns/Dockerfile --tag "gcr.io/${GCLOUD_PROJECT}/coturn-dns:${VERSION}"
|
|
|
|
|
- docker push "gcr.io/${GCLOUD_PROJECT}/coturn-dns:${VERSION}"
|
|
|
|
|
services:
|
|
|
|
|
- docker
|
2026-01-11 19:11:01 +00:00
|
|
|
run-staging-test:
|
|
|
|
|
- step:
|
|
|
|
|
name: Verify and Test Staging
|
|
|
|
|
deployment: staging
|
|
|
|
|
image: node:22
|
|
|
|
|
script:
|
|
|
|
|
- apt-get update && apt-get install -y curl jq git
|
2026-02-07 04:13:25 +00:00
|
|
|
- curl -LO "https://dl.k8s.io/release/v1.28.3/bin/linux/amd64/kubectl"
|
2026-01-11 19:11:01 +00:00
|
|
|
- install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
|
|
|
|
|
- echo $KUBE_CONFIG_STG | base64 -d > kubeconfig
|
|
|
|
|
- export KUBECONFIG=$(pwd)/kubeconfig
|
|
|
|
|
- npx playwright install-deps
|
|
|
|
|
- chmod +x scripts/verify-deployment.sh
|
|
|
|
|
- ./scripts/verify-deployment.sh $BITBUCKET_COMMIT staging
|
|
|
|
|
- git clone --depth 1 git@bitbucket.org:jamkazam/video-e2e.git
|
|
|
|
|
- cd video-e2e
|
|
|
|
|
- npm install
|
|
|
|
|
- npx playwright install chromium
|
|
|
|
|
- ./bin/staging-test
|
|
|
|
|
after-script:
|
2026-01-11 20:00:07 +00:00
|
|
|
- |
|
2026-01-11 19:18:59 +00:00
|
|
|
if [ $BITBUCKET_EXIT_CODE -ne 0 ]; then
|
2026-01-11 19:11:01 +00:00
|
|
|
curl -X POST -H 'Content-type: application/json' --data "{\"text\":\"🚨 Pipeline Failed: Staging verification/tests failed for commit $BITBUCKET_COMMIT. <https://bitbucket.org/$BITBUCKET_REPO_FULL_NAME/pipelines/results/$BITBUCKET_BUILD_NUMBER|View Log>\"}" https://hooks.slack.com/services/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
|
2026-01-11 21:35:30 +00:00
|
|
|
fi
|