Fix jwt-token
This commit is contained in:
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