46 lines
2.3 KiB
Bash
46 lines
2.3 KiB
Bash
#!/bin/bash
|
|
let "sufix=$RANDOM"
|
|
resourceGroup='vinayakrao715'
|
|
mysql_service='vinayakrao715-server'
|
|
registry='vinayakrao715'
|
|
domain="vinayakrao-$sufix"
|
|
|
|
echo "Start deploying"
|
|
az group create --name $resourceGroup --location eastus
|
|
az acr create --resource-group $resourceGroup --name $registry --admin-enabled true --sku basic
|
|
az acr login --name $registry
|
|
|
|
## Building docker image
|
|
docker build ./product-manager-backend -t product-manager-backend
|
|
docker build ./product-manager-frontend -t product-manager-frontend
|
|
|
|
# Tagging/Pushing docker image to ACR registry
|
|
docker tag product-manager-backend:latest $registry.azurecr.io/product-manager-backend:latest
|
|
docker tag product-manager-frontend:latest $registry.azurecr.io/product-manager-frontend:latest
|
|
|
|
docker push $registry.azurecr.io/product-manager-backend:latest
|
|
docker push $registry.azurecr.io/product-manager-frontend:latest
|
|
|
|
# Create a PostgreSQL server in the resource group
|
|
az postgres server create --name ${domain}-postgres --resource-group $resourceGroup --location eastus --admin-user 'postgres' --admin-password 'PassWod+fdads!' --sku-name GP_Gen5_2
|
|
|
|
# Configure a firewall rule for the server
|
|
az postgres server firewall-rule create --resource-group $resourceGroup --server ${domain}-postgres --name allMe --start-ip-address 0.0.0.0 --end-ip-address 0.0.0.0
|
|
|
|
registry_password=`az acr credential show -n vinayakrao715 --query passwords[0].value | tr -d '"' `
|
|
|
|
az container create --resource-group $resourceGroup --name product-manager-front \
|
|
--image $registry.azurecr.io/product-manager-frontend:latest \
|
|
--registry-password $registry_password --registry-username $registry \
|
|
--dns-name-label $domain --ports 80 --restart-policy OnFailure\
|
|
--environment-variables api_host="http://${domain}-backend.eastus.azurecontainer.io"
|
|
|
|
|
|
|
|
az container create --resource-group $resourceGroup --name product-manager-back \
|
|
--image $registry.azurecr.io/product-manager-backend:latest \
|
|
--registry-password $registry_password --registry-username $registry \
|
|
--dns-name-label "${domain}-backend" --ports 80 --restart-policy OnFailure \
|
|
--environment-variables POSTGRES_DB="postgres" POSTGRES_USER="postgres@${domain}-postgres" POSTGRES_PASSWORD="PassWod+fdads!" DATABASE_HOST="${domain}-postgres.postgres.database.azure.com"
|
|
|
|
echo "To open the website use : http://${domain}.eastus.azurecontainer.io" |