cinema-studio-pro/deploy-optical.sh
Vadym Samoilenko db4322bcd7 fix: rewrite deploy-optical.sh for Docker Compose pattern
git pull → docker compose up --build → Apache include (idempotent) → reload.
No longer assumes PHP/Node on host; runs without sudo except Apache steps.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-24 16:17:56 +01:00

83 lines
3.3 KiB
Bash
Executable file

#!/bin/bash
################################################################################
# Lux Studio — Optical-Prod Deployment Script
#
# Usage:
# cd /opt/cinema-studio-pro
# ./deploy-optical.sh
#
# Target: https://optical-prod.oliver.solutions/lux-studio/
#
# What it does:
# 1. git pull (plaiground branch)
# 2. docker compose build + up
# 3. Adds Apache include once (idempotent on re-deploy)
# 4. Reloads Apache
################################################################################
set -e
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
APACHE_VHOST="/etc/apache2/sites-enabled/optical-prod.oliver.solutions.conf"
APACHE_INCLUDE="Include /opt/cinema-studio-pro/deploy/apache-lux-studio.conf"
RED='\033[0;31m'; GREEN='\033[0;32m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
step() { echo ""; echo -e "${YELLOW}[$1] $2...${NC}"; }
ok() { echo -e "${GREEN}$1${NC}"; }
warn() { echo -e "${YELLOW}$1${NC}"; }
fail() { echo -e "${RED}$1${NC}"; exit 1; }
echo ""
echo -e "${BLUE}================================================"
echo -e " Lux Studio — optical-prod deploy"
echo -e "================================================${NC}"
echo " Dir: $SCRIPT_DIR"
echo " URL: https://optical-prod.oliver.solutions/lux-studio/"
echo ""
# ── 1. git pull ───────────────────────────────────────────────────────────────
step "1/4" "git pull"
cd "$SCRIPT_DIR"
git pull origin plaiground
ok "Code up to date ($(git rev-parse --short HEAD))"
# ── 2. Docker build + up ──────────────────────────────────────────────────────
step "2/4" "Building and starting container"
[ -f "backend/.env.optical" ] || fail "backend/.env.optical not found"
docker compose -f docker-compose.prod.yml up -d --build
ok "Container up"
# ── 3. Apache include (idempotent) ────────────────────────────────────────────
step "3/4" "Apache include"
if grep -qF "$APACHE_INCLUDE" "$APACHE_VHOST" 2>/dev/null; then
ok "Include already present — skipping"
else
if [ -f "$APACHE_VHOST" ]; then
# Insert include before closing </VirtualHost>
sudo sed -i "s|</VirtualHost>| $APACHE_INCLUDE\n</VirtualHost>|" "$APACHE_VHOST"
ok "Include added to $APACHE_VHOST"
else
warn "$APACHE_VHOST not found — add manually:"
warn " $APACHE_INCLUDE"
fi
fi
# ── 4. Reload Apache ──────────────────────────────────────────────────────────
step "4/4" "Reloading Apache"
sudo apache2ctl configtest 2>&1 | grep -v "^$" || true
sudo systemctl reload apache2
ok "Apache reloaded"
echo ""
echo -e "${GREEN} Deploy complete!${NC}"
echo -e " → https://optical-prod.oliver.solutions/lux-studio/"
echo ""
echo -e "${BLUE} Useful commands:${NC}"
echo " Logs: docker compose -f docker-compose.prod.yml logs -f"
echo " Restart: docker compose -f docker-compose.prod.yml restart"
echo " Re-deploy: cd $SCRIPT_DIR && ./deploy-optical.sh"
echo ""