55 lines
1.6 KiB
Bash
55 lines
1.6 KiB
Bash
#!/bin/bash
|
|
# deploy.sh — Build auto-retrieve-files-from-a-reposito image in ACR and deploy to AKS
|
|
set -e
|
|
|
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
|
ACR_NAME="bstagecjotdevacr"
|
|
APP_NAME="auto-retrieve-files-from-a-reposito"
|
|
NAMESPACE="agents"
|
|
VERSION_FILE="${SCRIPT_DIR}/../.image-version"
|
|
TAG=""
|
|
|
|
while [[ "$#" -gt 0 ]]; do
|
|
case $1 in
|
|
--tag) TAG="$2"; shift ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
if [ -z "$TAG" ]; then
|
|
if [ -f "$VERSION_FILE" ]; then
|
|
CURRENT_VERSION=$(cat "$VERSION_FILE")
|
|
else
|
|
CURRENT_VERSION="1.0.0"
|
|
fi
|
|
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
|
|
PATCH=$((PATCH + 1))
|
|
TAG="${MAJOR}.${MINOR}.${PATCH}"
|
|
echo "$TAG" > "$VERSION_FILE"
|
|
fi
|
|
|
|
IMAGE="${ACR_NAME}.azurecr.io/${APP_NAME}:${TAG}"
|
|
|
|
echo "======================================================================"
|
|
echo " auto-retrieve-files-from-a-reposito — Build & Deploy"
|
|
echo " Image: ${IMAGE}"
|
|
echo "======================================================================"
|
|
|
|
az acr build --registry ${ACR_NAME} \
|
|
--image ${APP_NAME}:${TAG} \
|
|
--image ${APP_NAME}:latest \
|
|
"${SCRIPT_DIR}/.."
|
|
|
|
kubectl apply -f "${SCRIPT_DIR}/../k8s/configmap.yaml" 2>/dev/null || true
|
|
kubectl apply -f "${SCRIPT_DIR}/../k8s/deployment.yaml"
|
|
kubectl apply -f "${SCRIPT_DIR}/../k8s/service.yaml" 2>/dev/null || true
|
|
|
|
kubectl set image deployment/${APP_NAME} \
|
|
${APP_NAME}=${IMAGE} \
|
|
-n ${NAMESPACE}
|
|
|
|
kubectl rollout status deployment/${APP_NAME} -n ${NAMESPACE} --timeout=120s
|
|
|
|
echo "✓ Done. Image: ${IMAGE}"
|
|
echo " Port forward: kubectl port-forward -n ${NAMESPACE} deployment/${APP_NAME} 8080:8080"
|