#!/bin/bash set -e # ── 1. Start AgentScope Python backend on port 8000 ─────────────────────────── echo "🐍 Starting AgentScope backend on :8000..." cd /app/backend uvicorn main:app --host 0.0.0.0 --port 8000 & BACKEND_PID=$! # ── 2. Wait for backend ─────────────────────────────────────────────────────── sleep 3 # ── 3. Start nginx reverse proxy on port 7860 ──────────────────────────────── echo "🔀 Starting nginx on :7860..." mkdir -p /tmp/nginx_client_body /tmp/nginx_proxy /tmp/nginx_fastcgi \ /tmp/nginx_uwsgi /tmp/nginx_scgi cat > /tmp/nginx.conf << 'NGINXEOF' worker_processes 1; pid /tmp/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; client_body_temp_path /tmp/nginx_client_body; proxy_temp_path /tmp/nginx_proxy; fastcgi_temp_path /tmp/nginx_fastcgi; uwsgi_temp_path /tmp/nginx_uwsgi; scgi_temp_path /tmp/nginx_scgi; server { listen 7860; # Serve custom frontend (index.html, multiagent.html, static files) root /app/frontend; index index.html; # SSE: disable buffering proxy_buffering off; # Custom frontend root location / { try_files $uri $uri/ /index.html; } # Python backend API location /api/ { proxy_pass http://localhost:8000/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_read_timeout 300s; } } } NGINXEOF nginx -c /tmp/nginx.conf & NGINX_PID=$! echo "✅ All services running:" echo " Frontend → :7860 (custom UI)" echo " Backend → :8000/api/" wait $BACKEND_PID $NGINX_PID