#!/bin/bash # deploy.sh - Production Deployment Script for TFM aInventory # Forces Docker Compose to use the inventory.env file for both host and container. echo "๐Ÿณ TFM aInventory - Starting Deployment..." # 1. Check for configuration file if [ ! -f "inventory.env" ]; then echo "โŒ ERROR: inventory.env not found!" echo "Please create it or use the template provided." exit 1 fi # 2. Source the env file for the current shell (helps some docker versions) export $(grep -v '^#' inventory.env | xargs) # 3. Optional: Reset Caddy certificates if needed if [[ "$*" == *"--reset-ssl"* ]]; then echo "๐Ÿงน Resetting Caddy certificates..." docker compose down docker volume rm ainventory_caddy_data ainventory_caddy_config 2>/dev/null || true fi # 4. Run Docker Compose with explicit env-file flag echo "๐Ÿš€ Building and starting containers..." docker compose --env-file inventory.env up -d --build --remove-orphans echo "" echo "๐Ÿ” Verifying port mapping..." docker compose ps --format "table {{.Name}}\t{{.Status}}\t{{.Ports}}" echo "" echo "๐Ÿš€ DIAGNOSTIC LOGS (Proxy SSL Handshake):" docker compose logs proxy --tail 20 echo "" echo "โœ… Deployment requested." echo " ------------------------------------------------------------" echo " 1. SECURE ACCESS (Try first): https://${SERVER_IP:-localhost}:${FRONTEND_SSL_PORT:-8919}" echo " 2. DIRECT ACCESS (Fallback): http://${SERVER_IP:-localhost}:${FRONTEND_PORT:-8917}" echo " ------------------------------------------------------------" echo ""