Files
voice-call-service/voice-call-service/deploy.sh

62 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# Production Deployment Script for Intaleq Voice Call Signaling Backend
# Exit immediately if any command exits with a non-zero status
set -e
echo "=========================================================="
echo " Starting Deploy process for Intaleq Voice Call Backend"
echo "=========================================================="
# 1. Check for configuration file
if [ -f ../.env ]; then
echo "[+] Found .env file in parent directory. Copying to current directory..."
cp ../.env .env
fi
if [ ! -f .env ]; then
echo "[-] ERROR: .env file not found."
echo "[*] Creating .env from .env.example..."
cp .env.example .env
echo "[!] Please edit .env with your production secrets (JWT_SECRET etc.) and run deploy.sh again."
exit 1
fi
# 2. Verify runtime dependencies
if ! command -v docker >/dev/null 2>&1; then
echo "[-] ERROR: Docker is not installed or not in PATH."
exit 1
fi
# Support both docker-compose plugin and standalone CLI
if docker compose version >/dev/null 2>&1; then
DOCKER_COMPOSE="docker compose"
elif command -v docker-compose >/dev/null 2>&1; then
DOCKER_COMPOSE="docker-compose"
else
echo "[-] ERROR: docker compose tool could not be found."
exit 1
fi
# 3. Build and recreate service containers
echo "[+] Starting Docker Compose build and reload..."
$DOCKER_COMPOSE down --remove-orphans
$DOCKER_COMPOSE up -d --build
# 4. Wait for bootstrap
echo "[+] Waiting for container startup (3s)..."
sleep 3
# 5. Verify deployment via health check script
echo "[+] Executing post-deployment health check..."
if ./scripts/healthcheck.sh; then
echo "=========================================================="
echo "[+] SUCCESS: Deployment completed and backend is healthy!"
echo "=========================================================="
exit 0
else
echo "=========================================================="
echo "[-] FAILED: Health check returned unhealthy status!"
echo "=========================================================="
exit 1
fi