-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-cometx-containerapps.ps1
More file actions
63 lines (54 loc) ยท 3.86 KB
/
setup-cometx-containerapps.ps1
File metadata and controls
63 lines (54 loc) ยท 3.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
$ErrorActionPreference = 'Stop'
$SUBSCRIPTION_ID = 'dde8416c-6077-4b2b-b722-05bf8b782c44'
$LOCATION = 'eastus2'
$RG = 'rg-cometx-prod'
$ENV = 'cometx-env' # ุงุณุชุฎุฏุงู
ุงูุจูุฆุฉ ุงูู
ูุฌูุฏุฉ
$APP_PROD = 'ca-cometx-api'
$APP_STG = 'ca-cometx-api-staging'
$TARGET_PORT = 5173
$IMAGE_PROD = 'ghcr.io/gratech-sa/gratech-cometx:latest'
$IMAGE_STG = 'ghcr.io/gratech-sa/gratech-cometx:staging'
$DOMAIN_ZONE = 'gratech.sa'
$DOMAIN_PROD = 'api.gratech.sa'
$DOMAIN_STG = 'staging.gratech.sa'
az account set --subscription $SUBSCRIPTION_ID
az extension add --name containerapp --upgrade
# ุงุณุชุฎุฏุงู
ุงูุจูุฆุฉ ุงูู
ูุฌูุฏุฉ ููุท
Write-Host "โ
ุงุณุชุฎุฏุงู
ุงูุจูุฆุฉ ุงูู
ูุฌูุฏุฉ: $ENV" -ForegroundColor Green
# ุชุญุฏูุซ ุงูุชุทุจูู ุงูู
ูุฌูุฏ ุฃู ุฅูุดุงุก staging
Write-Host "`n๐ฆ ุชุญุฏูุซ/ุฅูุดุงุก ุงูุชุทุจููุงุช..." -ForegroundColor Cyan
try {
az containerapp show -g $RG -n $APP_PROD -o none 2>$null
Write-Host "โ $APP_PROD ู
ูุฌูุฏ - ุณูุชู
ุชุญุฏูุซู" -ForegroundColor Yellow
az containerapp update -g $RG -n $APP_PROD --image $IMAGE_PROD
} catch {
Write-Host "โ ุฅูุดุงุก $APP_PROD" -ForegroundColor Green
az containerapp create -g $RG -n $APP_PROD --environment $ENV --image $IMAGE_PROD --ingress external --target-port $TARGET_PORT
}
try {
az containerapp show -g $RG -n $APP_STG -o none 2>$null
Write-Host "โ $APP_STG ู
ูุฌูุฏ - ุณูุชู
ุชุญุฏูุซู" -ForegroundColor Yellow
az containerapp update -g $RG -n $APP_STG --image $IMAGE_STG
} catch {
Write-Host "โ ุฅูุดุงุก $APP_STG" -ForegroundColor Green
az containerapp create -g $RG -n $APP_STG --environment $ENV --image $IMAGE_STG --ingress external --target-port $TARGET_PORT
}
$APP_PROD_FQDN = az containerapp show -g $RG -n $APP_PROD --query 'properties.configuration.ingress.fqdn' -o tsv
$APP_STG_FQDN = az containerapp show -g $RG -n $APP_STG --query 'properties.configuration.ingress.fqdn' -o tsv
Write-Host "`nโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ" -ForegroundColor Cyan
Write-Host " ๐ ู
ุนููู
ุงุช DNS:" -ForegroundColor Yellow
Write-Host "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ" -ForegroundColor Cyan
Write-Host "CNAME api.gratech.sa -> $APP_PROD_FQDN" -ForegroundColor Green
Write-Host "CNAME staging.gratech.sa -> $APP_STG_FQDN" -ForegroundColor Green
Write-Host 'CAA (root): 0 issue "digicert.com"' -ForegroundColor Yellow
Write-Host "โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ" -ForegroundColor Cyan
Write-Host "`n๐ ุฅุถุงูุฉ ุงููุทุงูุงุช ุงูู
ุฎุตุตุฉ ู
ุน Managed Certificates..." -ForegroundColor Cyan
az containerapp hostname add --hostname $DOMAIN_PROD -g $RG -n $APP_PROD
az containerapp hostname bind --hostname $DOMAIN_PROD -g $RG -n $APP_PROD --environment $ENV --validation-method CNAME
az containerapp hostname add --hostname $DOMAIN_STG -g $RG -n $APP_STG
az containerapp hostname bind --hostname $DOMAIN_STG -g $RG -n $APP_STG --environment $ENV --validation-method CNAME
Write-Host "`nโ
ุชู
! ุฑุงุฌุน ุงูุชุทุจููุงุช:" -ForegroundColor Green
Write-Host " Production: https://$APP_PROD_FQDN" -ForegroundColor White
Write-Host " Staging: https://$APP_STG_FQDN" -ForegroundColor White
Write-Host " Custom Prod: https://$DOMAIN_PROD (ุจุนุฏ DNS)" -ForegroundColor White
Write-Host " Custom Stg: https://$DOMAIN_STG (ุจุนุฏ DNS)" -ForegroundColor White