-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy.sh
More file actions
executable file
·40 lines (32 loc) · 1.38 KB
/
deploy.sh
File metadata and controls
executable file
·40 lines (32 loc) · 1.38 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
#!/usr/bin/env zsh
set -e
VERSION=$(git rev-parse --short HEAD)
echo "Deploying version $VERSION"
# 1. Build the Docker Image
echo "Building Docker image..."
docker build -t policywonkcontainers.azurecr.io/policyacquisition:$VERSION .
# 2. Fetch registry credentials
echo "Fetching Azure Container Registry credentials..."
REGISTRY_NAME="policywonkcontainers"
ACR_CREDENTIALS=$(az acr credential show --name $REGISTRY_NAME --query "{username:username, password:passwords[0].value}" -o tsv)
ACR_USERNAME=$(echo $ACR_CREDENTIALS | cut -f1)
ACR_PASSWORD=$(echo $ACR_CREDENTIALS | cut -f2)
# 3. Login to Azure Container Registry using fetched credentials
echo "Logging into Azure Container Registry..."
echo $ACR_PASSWORD | docker login policywonkcontainers.azurecr.io -u $ACR_USERNAME --password-stdin
# 4. Push the Docker Image
echo "Pushing Docker image..."
docker push policywonkcontainers.azurecr.io/policyacquisition:$VERSION
# 5. Update the Azure Container Instance
echo "Updating Azure Container Instance..."
az container create \
--resource-group policy \
--name policyacquisition \
--cpu 1 \
--memory 8 \
--restart-policy OnFailure \
--image policywonkcontainers.azurecr.io/policyacquisition:$VERSION \
--registry-login-server policywonkcontainers.azurecr.io \
--registry-username $ACR_USERNAME \
--registry-password $ACR_PASSWORD
echo "Deployment of version $VERSION completed."