-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_and_deploy.sh
More file actions
47 lines (38 loc) · 1.23 KB
/
build_and_deploy.sh
File metadata and controls
47 lines (38 loc) · 1.23 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
#!/bin/bash
set -e
# Configuration
RESOURCE_GROUP="givecare"
ACR_NAME="givecareregistry"
APP_NAME="digital-being"
IMAGE_NAME="digital-being"
IMAGE_TAG="latest"
# Login to Azure
echo "Logging into Azure..."
az account show > /dev/null || az login
# Login to ACR
echo "Logging into Azure Container Registry..."
az acr login --name $ACR_NAME
# Build the image
echo "Building Docker image..."
docker build -t $IMAGE_NAME:$IMAGE_TAG .
# Tag the image for ACR
echo "Tagging image for ACR..."
docker tag $IMAGE_NAME:$IMAGE_TAG $ACR_NAME.azurecr.io/$IMAGE_NAME:$IMAGE_TAG
# Push to ACR
echo "Pushing image to ACR..."
docker push $ACR_NAME.azurecr.io/$IMAGE_NAME:$IMAGE_TAG
# Update the web app to use the container
echo "Updating App Service to use container..."
az webapp config container set \
--resource-group $RESOURCE_GROUP \
--name $APP_NAME \
--docker-custom-image-name $ACR_NAME.azurecr.io/$IMAGE_NAME:$IMAGE_TAG \
--docker-registry-server-url https://$ACR_NAME.azurecr.io
# Set website to always on
echo "Configuring App Service settings..."
az webapp config set \
--resource-group $RESOURCE_GROUP \
--name $APP_NAME \
--always-on true
echo "Deployment complete!"
echo "Your app should be available at: https://$APP_NAME.azurewebsites.net"