155 lines
4.4 KiB
Batchfile
155 lines
4.4 KiB
Batchfile
@echo off
|
|
setlocal enabledelayedexpansion
|
|
|
|
REM Drone Detection System - Docker Quick Start Script (Windows)
|
|
REM This script sets up and starts the complete system using Docker
|
|
|
|
echo 🐳 Drone Detection System - Docker Setup
|
|
echo ========================================
|
|
|
|
REM Check if Docker is installed
|
|
docker --version >nul 2>&1
|
|
if %errorlevel% neq 0 (
|
|
echo [ERROR] Docker is not installed. Please install Docker Desktop first.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
REM Check if Docker Compose is installed
|
|
docker compose --version >nul 2>&1
|
|
if %errorlevel% neq 0 (
|
|
echo [ERROR] Docker Compose is not installed. Please install Docker Compose first.
|
|
pause
|
|
exit /b 1
|
|
)
|
|
|
|
echo [INFO] Docker and Docker Compose are available
|
|
|
|
REM Create .env file if it doesn't exist
|
|
if not exist .env (
|
|
echo [INFO] Creating .env file from template...
|
|
copy .env.docker .env >nul
|
|
echo [WARNING] Please edit .env file with your Twilio credentials before continuing
|
|
echo Required variables:
|
|
echo - TWILIO_ACCOUNT_SID
|
|
echo - TWILIO_AUTH_TOKEN
|
|
echo - TWILIO_PHONE_NUMBER
|
|
echo.
|
|
pause
|
|
)
|
|
|
|
REM Parse command line arguments
|
|
set PROFILE=default
|
|
set DETACH=-d
|
|
set BUILD=
|
|
|
|
:parse_args
|
|
if "%~1"=="" goto start_services
|
|
if "%~1"=="--production" set PROFILE=production
|
|
if "%~1"=="-p" set PROFILE=production
|
|
if "%~1"=="--simulation" set PROFILE=simulation
|
|
if "%~1"=="-s" set PROFILE=simulation
|
|
if "%~1"=="--foreground" set DETACH=
|
|
if "%~1"=="-f" set DETACH=
|
|
if "%~1"=="--build" set BUILD=--build
|
|
if "%~1"=="-b" set BUILD=--build
|
|
if "%~1"=="--help" goto show_help
|
|
if "%~1"=="-h" goto show_help
|
|
shift
|
|
goto parse_args
|
|
|
|
:show_help
|
|
echo Usage: %~nx0 [OPTIONS]
|
|
echo.
|
|
echo Options:
|
|
echo -p, --production Run with production profile (includes Nginx)
|
|
echo -s, --simulation Run with simulation profile (includes drone simulator)
|
|
echo -f, --foreground Run in foreground (don't detach)
|
|
echo -b, --build Force rebuild of containers
|
|
echo -h, --help Show this help message
|
|
echo.
|
|
echo Examples:
|
|
echo %~nx0 # Start basic system
|
|
echo %~nx0 -p # Start with production setup
|
|
echo %~nx0 -s -f # Start with simulation in foreground
|
|
echo %~nx0 -b # Rebuild and start
|
|
pause
|
|
exit /b 0
|
|
|
|
:start_services
|
|
REM Stop any existing containers
|
|
echo [INFO] Stopping any existing containers...
|
|
docker compose down 2>nul
|
|
|
|
REM Build containers if requested
|
|
if not "%BUILD%"=="" (
|
|
echo [INFO] Building Docker containers...
|
|
docker compose build
|
|
)
|
|
|
|
REM Start the appropriate profile
|
|
if "%PROFILE%"=="production" (
|
|
echo [INFO] Starting production environment...
|
|
docker compose --profile production up %DETACH% %BUILD%
|
|
) else if "%PROFILE%"=="simulation" (
|
|
echo [INFO] Starting with simulation environment...
|
|
docker compose --profile simulation up %DETACH% %BUILD%
|
|
) else (
|
|
echo [INFO] Starting development environment...
|
|
docker compose up %DETACH% %BUILD%
|
|
)
|
|
|
|
REM Wait a moment for services to start
|
|
if not "%DETACH%"=="" (
|
|
echo [INFO] Waiting for services to start...
|
|
timeout /t 10 /nobreak >nul
|
|
|
|
echo [INFO] Checking service health...
|
|
|
|
REM Check backend
|
|
curl -sf http://localhost:3001/api/health >nul 2>&1
|
|
if %errorlevel% equ 0 (
|
|
echo [SUCCESS] Backend is healthy
|
|
) else (
|
|
echo [WARNING] Backend health check failed
|
|
)
|
|
|
|
REM Check frontend
|
|
curl -sf http://localhost:3000 >nul 2>&1
|
|
if %errorlevel% equ 0 (
|
|
echo [SUCCESS] Frontend is healthy
|
|
) else (
|
|
echo [WARNING] Frontend health check failed
|
|
)
|
|
|
|
echo.
|
|
echo [SUCCESS] 🎉 Drone Detection System is running!
|
|
echo.
|
|
echo Access URLs:
|
|
echo Frontend: http://localhost:3000
|
|
echo Backend: http://localhost:3001/api
|
|
echo Health: http://localhost:3001/api/health
|
|
echo.
|
|
echo Default login credentials:
|
|
echo Admin: admin / admin123
|
|
echo Operator: operator / operator123
|
|
echo.
|
|
echo Useful commands:
|
|
echo docker compose logs -f # View logs
|
|
echo docker compose ps # Check status
|
|
echo docker compose down # Stop services
|
|
echo docker compose restart backend # Restart a service
|
|
echo.
|
|
|
|
if "%PROFILE%"=="simulation" (
|
|
echo 🐍 Simulation is running!
|
|
echo Monitor with: docker compose logs -f simulator
|
|
echo.
|
|
)
|
|
) else (
|
|
echo.
|
|
echo [INFO] Services are running in foreground. Press Ctrl+C to stop.
|
|
)
|
|
|
|
pause
|