Files
cam_control/rebuild.sh
2025-12-09 20:28:46 +09:00

62 lines
1.6 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
# Скрипт для обновления и пересборки Docker контейнера
set -e
echo "=========================================="
echo "🔄 Updating Camera Server Container"
echo "=========================================="
# Проверяем, находимся ли в корректной директории
if [ ! -f "docker compose.yml" ]; then
echo "❌ Error: docker-compose.yml not found"
echo "Please run this script from the project root directory"
exit 1
fi
echo ""
echo "1⃣ Stopping container..."
docker compose down
echo ""
echo "2⃣ Rebuilding image..."
docker compose build --no-cache
echo ""
echo "3⃣ Starting container..."
docker compose up -d
echo ""
echo "4⃣ Waiting for container to be ready..."
sleep 3
echo ""
echo "5⃣ Checking container status..."
docker compose ps
echo ""
echo "6⃣ Recent logs:"
docker compose logs --tail 20
echo ""
echo "=========================================="
echo "✅ Update complete!"
echo "=========================================="
echo ""
echo "Server should be running on:"
docker compose exec camera_server python3 -c "
import os
from dotenv import load_dotenv
load_dotenv()
bind_host = os.getenv('BIND_HOST', '0.0.0.0')
public_host = os.getenv('PUBLIC_HOST', 'localhost')
port = os.getenv('PORT', '8000')
print(f' 📡 Public: http://{public_host}:{port}')
print(f' 🔗 Local: http://127.0.0.1:{port}')
" 2>/dev/null || echo " 📡 Check .env for PUBLIC_HOST and PORT"
echo ""
echo "To view logs in real-time:"
echo " docker-compose logs -f"y
echo ""