-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path01-build-and-push-docker-images-podman.sh
52 lines (43 loc) · 1.48 KB
/
01-build-and-push-docker-images-podman.sh
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
#!/bin/bash
# Variables
source ./00-variables.sh
# Ensure Podman is installed and running
if ! podman info > /dev/null 2>&1; then
echo "Podman is not installed or running. Please install/start Podman and try again."
exit 1
fi
echo ""
echo "========================================================"
echo " Building the chat app container with version $tag"
echo "========================================================"
echo ""
podman build -t ${chatImageName}:$tag -f Dockerfile --build-arg FILENAME=app.py --build-arg PORT=$port .
# Tag the image with ACR repository name
podman tag ${chatImageName}:$tag testregistry1234.azurecr.io/${chatImageName}:$tag
echo ""
echo "========================================================"
printf 'Do you want to push the image (y/n)? '
read answer
if [ "$answer" != "${answer#[Yy]}" ] ;then
# Log in to ACR using Podman
echo "Logging in to ACR..."
TOKEN=$(az acr login --name ${acrName} --expose-token | jq -r '.accessToken')
if [ -z "$TOKEN" ]; then
echo "Failed to retrieve access token."
exit 1
fi
podman login ${acrLoginServer} --username 00000000-0000-0000-0000-000000000000 --password $TOKEN
if [ $? -ne 0 ]; then
echo "Failed to log in to ACR."
exit 1
fi
# Push the image to ACR
echo "Pushing the image to ACR..."
podman push ${acrLoginServer}/${chatImageName}:$tag
if [ $? -ne 0 ]; then
echo "Failed to push the image to ACR."
exit 1
fi
else
exit
fi