Fix jwt-token
This commit is contained in:
154
docker-start.bat
154
docker-start.bat
@@ -1,154 +0,0 @@
|
|||||||
@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
|
|
||||||
191
docker-start.sh
191
docker-start.sh
@@ -1,191 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
# Drone Detection System - Docker Quick Start Script
|
|
||||||
# This script sets up and starts the complete system using Docker
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
echo "🐳 Drone Detection System - Docker Setup"
|
|
||||||
echo "========================================"
|
|
||||||
|
|
||||||
# Colors for output
|
|
||||||
RED='\033[0;31m'
|
|
||||||
GREEN='\033[0;32m'
|
|
||||||
YELLOW='\033[1;33m'
|
|
||||||
BLUE='\033[0;34m'
|
|
||||||
NC='\033[0m' # No Color
|
|
||||||
|
|
||||||
# Function to print colored output
|
|
||||||
print_status() {
|
|
||||||
echo -e "${BLUE}[INFO]${NC} $1"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_success() {
|
|
||||||
echo -e "${GREEN}[SUCCESS]${NC} $1"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_warning() {
|
|
||||||
echo -e "${YELLOW}[WARNING]${NC} $1"
|
|
||||||
}
|
|
||||||
|
|
||||||
print_error() {
|
|
||||||
echo -e "${RED}[ERROR]${NC} $1"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Check if Docker is installed
|
|
||||||
if ! command -v docker &> /dev/null; then
|
|
||||||
print_error "Docker is not installed. Please install Docker first."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if Docker Compose is installed
|
|
||||||
if ! command -v docker compose &> /dev/null; then
|
|
||||||
print_error "Docker Compose is not installed. Please install Docker Compose first."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
print_status "Docker and Docker Compose are available"
|
|
||||||
|
|
||||||
# Create .env file if it doesn't exist
|
|
||||||
if [ ! -f .env ]; then
|
|
||||||
print_status "Creating .env file from template..."
|
|
||||||
cp .env.docker .env
|
|
||||||
print_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 ""
|
|
||||||
read -p "Press Enter to continue when .env is configured..."
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Parse command line arguments
|
|
||||||
PROFILE="default"
|
|
||||||
DETACH="-d"
|
|
||||||
BUILD=""
|
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
|
||||||
case $1 in
|
|
||||||
--production|-p)
|
|
||||||
PROFILE="production"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--simulation|-s)
|
|
||||||
PROFILE="simulation"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--foreground|-f)
|
|
||||||
DETACH=""
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--build|-b)
|
|
||||||
BUILD="--build"
|
|
||||||
shift
|
|
||||||
;;
|
|
||||||
--help|-h)
|
|
||||||
echo "Usage: $0 [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 " $0 # Start basic system"
|
|
||||||
echo " $0 -p # Start with production setup"
|
|
||||||
echo " $0 -s -f # Start with simulation in foreground"
|
|
||||||
echo " $0 -b # Rebuild and start"
|
|
||||||
exit 0
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
print_error "Unknown option: $1"
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# Stop any existing containers
|
|
||||||
print_status "Stopping any existing containers..."
|
|
||||||
docker compose down 2>/dev/null || true
|
|
||||||
|
|
||||||
# Build containers if requested
|
|
||||||
if [ -n "$BUILD" ]; then
|
|
||||||
print_status "Building Docker containers..."
|
|
||||||
docker compose build
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Start the appropriate profile
|
|
||||||
case $PROFILE in
|
|
||||||
"production")
|
|
||||||
print_status "Starting production environment..."
|
|
||||||
docker compose --profile production up $DETACH $BUILD
|
|
||||||
;;
|
|
||||||
"simulation")
|
|
||||||
print_status "Starting with simulation environment..."
|
|
||||||
docker compose --profile simulation up $DETACH $BUILD
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
print_status "Starting development environment..."
|
|
||||||
docker compose up $DETACH $BUILD
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Wait a moment for services to start
|
|
||||||
if [ -n "$DETACH" ]; then
|
|
||||||
print_status "Waiting for services to start..."
|
|
||||||
sleep 10
|
|
||||||
|
|
||||||
# Check service health
|
|
||||||
print_status "Checking service health..."
|
|
||||||
|
|
||||||
# Check backend
|
|
||||||
if curl -sf http://localhost:3001/api/health > /dev/null 2>&1; then
|
|
||||||
print_success "Backend is healthy"
|
|
||||||
else
|
|
||||||
print_warning "Backend health check failed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check frontend
|
|
||||||
if curl -sf http://localhost:3000 > /dev/null 2>&1; then
|
|
||||||
print_success "Frontend is healthy"
|
|
||||||
else
|
|
||||||
print_warning "Frontend health check failed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check database
|
|
||||||
if docker compose exec -T postgres pg_isready -U postgres > /dev/null 2>&1; then
|
|
||||||
print_success "Database is healthy"
|
|
||||||
else
|
|
||||||
print_warning "Database health check failed"
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
|
||||||
print_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" ]; then
|
|
||||||
echo "🐍 Simulation is running!"
|
|
||||||
echo " Monitor with: docker compose logs -f simulator"
|
|
||||||
echo ""
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo ""
|
|
||||||
print_status "Services are running in foreground. Press Ctrl+C to stop."
|
|
||||||
fi
|
|
||||||
Reference in New Issue
Block a user