canva-render/deploy.sh

78 lines
2.3 KiB
Bash
Raw Normal View History

2023-12-19 06:39:13 +00:00
ssh_start_port=12001
deply_start_port=8001
bastion_list="10
12
13
15
11
17
18
25"
project_urls="https://www.canva.com/design/DAFxmaf2y_Y/VMZhoqHPmqCV4zoDmkhzaw/edit
https://www.canva.com/design/DAFxmcF74iw/NRJcb0bvg0kN25HSUvWTPw/edit
https://www.canva.com/design/DAFxmVPAylk/JQCYHj2fE7qwMbvFstNptw/edit
https://www.canva.com/design/DAFxmcQATfQ/ZnbWUc_6so4yH1LzK9bwcA/edit
https://www.canva.com/design/DAFxmeOxIMo/Ucfx9UDFhg0RYx9w9HKiTw/edit
https://www.canva.com/design/DAFxmcvwu_E/lw-7caSNYuS6UlGr_rc8yQ/edit
https://www.canva.com/design/DAFxmfTKoe4/seL09fsTLv_n8Jm-HsfvYA/edit
https://www.canva.com/design/DAFxmUgjAkk/mIGcfJe8PWHFUBgzQSQ-mg/edit"
runtime=nerdctl
do_ssh () {
# $1: port
# $2: command
ssh -o StrictHostKeyChecking=no -p $1 REDMOND.v-lixinyang@localhost -- "$2"
}
create_tunnel () {
ssh_port=$ssh_start_port
for bastion in $bastion_list
do
sudo fuser -k $ssh_port/tcp
sudo az network bastion tunnel --subscription 7ccdb8ae-4daf-4f0f-8019-e80665eb00d2 --name CPU-Sandbox-VNET-bastion --resource-group CPU-SANDBOX --target-resource-id /subscriptions/7ccdb8ae-4daf-4f0f-8019-e80665eb00d2/resourceGroups/CPU-SANDBOX/providers/Microsoft.Compute/virtualMachines/GCRAZCDL00$bastion --resource-port 22 --port $ssh_port &
ssh_port=$((ssh_port + 1));
done
sleep 10
}
do_create_docker () {
create_tunnel
ssh_port=$ssh_start_port
for url in $project_urls
do
do_ssh $ssh_port "sudo $runtime rm --force canva-render; sudo $runtime pull msroctocr.azurecr.io/v-lixinyang/canva-render; sudo $runtime run --network=host -d -e CANVA_EDIT_URL=\"$url\" --name=canva-render msroctocr.azurecr.io/v-lixinyang/canva-render;"
ssh_port=$((ssh_port + 1))
done
}
do_pull_log () {
create_tunnel
ssh_port=$ssh_start_port
for url in $project_urls
do
do_ssh $ssh_port "sudo $runtime logs --tail 40 canva-render"
ssh_port=$((ssh_port + 1))
done
}
do_install_nerdctl () {
create_tunnel
ssh_port=$ssh_start_port
for url in $project_urls
do
do_ssh $ssh_port "wget https://github.com/containerd/nerdctl/releases/download/v1.6.2/nerdctl-1.6.2-linux-amd64.tar.gz; tar xvf nerdctl-1.6.2-linux-amd64.tar.gz; sudo mv nerdctl /usr/bin"
ssh_port=$((ssh_port + 1))
done
}
set -x
# do_install_nerdctl
# do_create_docker
do_pull_log