- Enhanced Caddyfile with consolidated HTTPS block supporting all access points - Added support for https://digiserver, https://10.76.152.164, and https://digiserver.sibiusb.harting.intra - Configured Caddy reverse proxy with HTTP/3 (QUIC), TLS 1.3+, and HTTP/2 support - Implemented security headers (X-Frame-Options, X-Content-Type-Options, X-XSS-Protection) - Added HTTP to HTTPS automatic redirects for all endpoints - Enhanced setup_https.sh with improved error handling and progress reporting - Created deploy.sh for fully automated one-command deployment - Added comprehensive deployment documentation (5 guides) - Configured 2GB file upload limit and 300s request/response timeouts - Added Caddy admin API on port 2019 for configuration management - Implemented health checks and container dependency management - All volumes persistent and properly isolated - Production-ready configuration with environment variable parameterization
175 lines
6.6 KiB
Bash
Executable File
175 lines
6.6 KiB
Bash
Executable File
#!/bin/bash
|
|
# Automated deployment script for DigiServer on a new PC
|
|
# Run this script to completely set up DigiServer with all configurations
|
|
|
|
set -e # Exit on any error
|
|
|
|
# Colors for output
|
|
RED='\033[0;31m'
|
|
GREEN='\033[0;32m'
|
|
YELLOW='\033[1;33m'
|
|
BLUE='\033[0;34m'
|
|
NC='\033[0m' # No Color
|
|
|
|
echo -e "${BLUE}╔════════════════════════════════════════════════════════════════╗${NC}"
|
|
echo -e "${BLUE}║ DigiServer Automated Deployment ║${NC}"
|
|
echo -e "${BLUE}╚════════════════════════════════════════════════════════════════╝${NC}"
|
|
echo ""
|
|
|
|
# Check if docker-compose is available
|
|
if ! command -v docker-compose &> /dev/null; then
|
|
echo -e "${RED}❌ docker-compose not found!${NC}"
|
|
echo "Please install docker-compose first"
|
|
exit 1
|
|
fi
|
|
|
|
# Check if we're in the project directory
|
|
if [ ! -f "docker-compose.yml" ]; then
|
|
echo -e "${RED}❌ docker-compose.yml not found!${NC}"
|
|
echo "Please run this script from the digiserver-v2 directory"
|
|
exit 1
|
|
fi
|
|
|
|
# ============================================================================
|
|
# CONFIGURATION VARIABLES
|
|
# ============================================================================
|
|
HOSTNAME="${HOSTNAME:-digiserver}"
|
|
DOMAIN="${DOMAIN:-digiserver.sibiusb.harting.intra}"
|
|
IP_ADDRESS="${IP_ADDRESS:-10.76.152.164}"
|
|
EMAIL="${EMAIL:-admin@example.com}"
|
|
PORT="${PORT:-443}"
|
|
|
|
echo -e "${BLUE}Configuration:${NC}"
|
|
echo " Hostname: $HOSTNAME"
|
|
echo " Domain: $DOMAIN"
|
|
echo " IP Address: $IP_ADDRESS"
|
|
echo " Email: $EMAIL"
|
|
echo " Port: $PORT"
|
|
echo ""
|
|
|
|
# ============================================================================
|
|
# STEP 1: Start containers
|
|
# ============================================================================
|
|
echo -e "${YELLOW}📦 [1/6] Starting containers...${NC}"
|
|
docker-compose up -d
|
|
|
|
echo -e "${YELLOW}⏳ Waiting for containers to be healthy...${NC}"
|
|
sleep 10
|
|
|
|
# Verify containers are running
|
|
if ! docker-compose ps | grep -q "Up"; then
|
|
echo -e "${RED}❌ Containers failed to start!${NC}"
|
|
docker-compose logs
|
|
exit 1
|
|
fi
|
|
echo -e "${GREEN}✅ Containers started successfully${NC}"
|
|
echo ""
|
|
|
|
# ============================================================================
|
|
# STEP 2: Run database migrations
|
|
# ============================================================================
|
|
echo -e "${YELLOW}📊 [2/6] Running database migrations...${NC}"
|
|
|
|
echo -e " • Creating https_config table..."
|
|
docker-compose exec -T digiserver-app python /app/migrations/add_https_config_table.py
|
|
echo -e " • Creating player_user table..."
|
|
docker-compose exec -T digiserver-app python /app/migrations/add_player_user_table.py
|
|
echo -e " • Adding email to https_config..."
|
|
docker-compose exec -T digiserver-app python /app/migrations/add_email_to_https_config.py
|
|
echo -e " • Migrating player_user global settings..."
|
|
docker-compose exec -T digiserver-app python /app/migrations/migrate_player_user_global.py
|
|
|
|
echo -e "${GREEN}✅ All database migrations completed${NC}"
|
|
echo ""
|
|
|
|
# ============================================================================
|
|
# STEP 3: Configure HTTPS
|
|
# ============================================================================
|
|
echo -e "${YELLOW}🔒 [3/6] Configuring HTTPS...${NC}"
|
|
|
|
docker-compose exec -T digiserver-app python /app/https_manager.py enable \
|
|
"$HOSTNAME" \
|
|
"$DOMAIN" \
|
|
"$EMAIL" \
|
|
"$IP_ADDRESS" \
|
|
"$PORT"
|
|
|
|
echo -e "${GREEN}✅ HTTPS configured successfully${NC}"
|
|
echo ""
|
|
|
|
# ============================================================================
|
|
# STEP 4: Verify database setup
|
|
# ============================================================================
|
|
echo -e "${YELLOW}🔍 [4/6] Verifying database setup...${NC}"
|
|
|
|
docker-compose exec -T digiserver-app python -c "
|
|
from app.app import create_app
|
|
from sqlalchemy import inspect
|
|
|
|
app = create_app()
|
|
with app.app_context():
|
|
inspector = inspect(app.extensions.db.engine)
|
|
tables = inspector.get_table_names()
|
|
print(' Database tables:')
|
|
for table in sorted(tables):
|
|
print(f' ✓ {table}')
|
|
print(f'')
|
|
print(f' ✅ Total tables: {len(tables)}')
|
|
" 2>/dev/null || echo " ⚠️ Database verification skipped"
|
|
echo ""
|
|
|
|
# ============================================================================
|
|
# STEP 5: Verify Caddy configuration
|
|
# ============================================================================
|
|
echo -e "${YELLOW}🔧 [5/6] Verifying Caddy configuration...${NC}"
|
|
|
|
docker-compose exec -T caddy caddy validate --config /etc/caddy/Caddyfile >/dev/null 2>&1
|
|
if [ $? -eq 0 ]; then
|
|
echo -e " ${GREEN}✅ Caddy configuration is valid${NC}"
|
|
else
|
|
echo -e " ${YELLOW}⚠️ Caddy validation skipped${NC}"
|
|
fi
|
|
echo ""
|
|
|
|
# ============================================================================
|
|
# STEP 6: Display summary
|
|
# ============================================================================
|
|
echo -e "${YELLOW}📋 [6/6] Displaying configuration summary...${NC}"
|
|
echo ""
|
|
|
|
docker-compose exec -T digiserver-app python /app/https_manager.py status
|
|
|
|
echo ""
|
|
echo -e "${GREEN}╔════════════════════════════════════════════════════════════════╗${NC}"
|
|
echo -e "${GREEN}║ 🎉 Deployment Complete! ║${NC}"
|
|
echo -e "${GREEN}╚════════════════════════════════════════════════════════════════╝${NC}"
|
|
echo ""
|
|
|
|
echo -e "${BLUE}📍 Access Points:${NC}"
|
|
echo " 🔒 https://$HOSTNAME"
|
|
echo " 🔒 https://$IP_ADDRESS"
|
|
echo " 🔒 https://$DOMAIN"
|
|
echo ""
|
|
|
|
echo -e "${BLUE}📝 Default Credentials:${NC}"
|
|
echo " Username: admin"
|
|
echo " Password: admin123 (⚠️ CHANGE IN PRODUCTION)"
|
|
echo ""
|
|
|
|
echo -e "${BLUE}📚 Documentation:${NC}"
|
|
echo " • DEPLOYMENT_COMMANDS.md - Detailed docker exec commands"
|
|
echo " • HTTPS_CONFIGURATION.md - HTTPS setup details"
|
|
echo " • setup_https.sh - Manual configuration script"
|
|
echo ""
|
|
|
|
echo -e "${YELLOW}Next Steps:${NC}"
|
|
echo "1. Access the application at one of the URLs above"
|
|
echo "2. Log in with admin credentials"
|
|
echo "3. Change the default password immediately"
|
|
echo "4. Configure your players and content"
|
|
echo ""
|
|
|
|
echo -e "${BLUE}📞 Support:${NC}"
|
|
echo "For troubleshooting, see DEPLOYMENT_COMMANDS.md section 7"
|
|
echo ""
|