#!/bin/bash set -e echo "=== Dikasterion Setup ===" # Check prerequisites if ! command -v docker &> /dev/null; then echo "Error: Docker not installed" exit 1 fi if ! command -v docker-compose &> /dev/null; then echo "Error: Docker Compose not installed" exit 1 fi # Create directories mkdir -p logs mkdir -p nginx/ssl # Create .env if not exists if [ ! -f .env ]; then echo "Creating .env file..." DB_PASS=$(openssl rand -base64 32 | tr -d "=+/" | cut -c1-32) SECRET=$(openssl rand -base64 64 | tr -d "=+/" | cut -c1-64) cat > .env << EOF DB_PASSWORD=${DB_PASS} SECRET_KEY=${SECRET} TELEGRAM_BOT_TOKEN= SMTP_HOST= SMTP_PORT=587 SMTP_USER= SMTP_PASSWORD= EOF echo ".env created with random passwords" else echo ".env already exists" fi # Build and start echo "Building containers..." docker-compose build echo "Starting services..." docker-compose up -d postgres # Wait for postgres echo "Waiting for PostgreSQL..." sleep 5 # Create tables echo "Creating database tables..." docker-compose exec backend python -c " from app.database import engine, Base import asyncio async def init(): async with engine.begin() as conn: await conn.run_sync(Base.metadata.create_all) asyncio.run(init()) " echo "" echo "=== Setup Complete ===" echo "" echo "Frontend: http://localhost:3000" echo "API: http://localhost:8000" echo "API Docs: http://localhost:8000/docs" echo "" echo "Next steps:" echo "1. Configure SSL certificates in nginx/ssl/" echo "2. Set Telegram bot token in .env (optional)" echo "3. Point dikasterion.org to this server" echo "4. Run: docker-compose up -d"