Update build and run scripts to support Apple's container.

This commit is contained in:
2025-12-21 23:59:00 +01:00
parent 5162b183bf
commit 4ff0a7205f
2 changed files with 35 additions and 25 deletions

View File

@@ -1,24 +1,37 @@
#!/bin/bash
#!/usr/bin/env bash
if [ -z "$AZURE_CLIENT_ID" ] || [ -z "$AZURE_TENANT_ID" ] || [ -z "$AZURE_CLIENT_SECRET" ] || [ -z "$AZURE_SUBSCRIPTION_ID" ]; then
echo "One or more environment variables are not set."
exit 1
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
if [ -f "$SCRIPT_DIR/azure.env" ]; then
source "$SCRIPT_DIR/azure.env"
fi
if [ "$(basename $(command -v docker))" = "docker" ]; then
REQUIRED_VARS=("AZURE_CLIENT_ID" "AZURE_TENANT_ID" "AZURE_CLIENT_SECRET" "AZURE_SUBSCRIPTION_ID")
for VAR in "${REQUIRED_VARS[@]}"; do
if [ -z "${!VAR}" ]; then
echo "Environment variable $VAR is not set."
exit 1
fi
done
IMAGE_NAME="azure-image-chooser"
IMAGE="docker.io/skoszewski/$IMAGE_NAME:latest"
RUN_ARGS=(
"--env" "AZURE_CLIENT_ID=$AZURE_CLIENT_ID"
"--env" "AZURE_TENANT_ID=$AZURE_TENANT_ID"
"--env" "AZURE_CLIENT_SECRET=$AZURE_CLIENT_SECRET"
"--env" "AZURE_SUBSCRIPTION_ID=$AZURE_SUBSCRIPTION_ID"
"-p" "8501:8501"
)
if command -v docker > /dev/null; then
CMD="docker"
elif [ "$(basename $(command -v podman))" = "podman" ]; then
CMD="podman"
elif command -v container > /dev/null; then
CMD="container"
else
echo "No suitable container tool found"
exit 1
fi
$CMD run --rm \
-it \
-e AZURE_CLIENT_ID="$AZURE_CLIENT_ID" \
-e AZURE_TENANT_ID="$AZURE_TENANT_ID" \
-e AZURE_CLIENT_SECRET="$AZURE_CLIENT_SECRET" \
-e AZURE_SUBSCRIPTION_ID="$AZURE_SUBSCRIPTION_ID" \
-p 8501:8501 \
azure-image-chooser
$CMD run --rm -it "${RUN_ARGS[@]}" $IMAGE