#!/bin/bash set -e echo "🚀 Starting VSCode AI Space..." # ======================== # Prepare nginx runtime dirs # ======================== mkdir -p /tmp/nginx/body mkdir -p /tmp/nginx/proxy mkdir -p /tmp/nginx/fastcgi mkdir -p /tmp/nginx/uwsgi mkdir -p /tmp/nginx/scgi # ======================== # Auth # ======================== NGX_NAME="${NGX_NAME:-admin}" NGX_PASS="${NGX_PASS:-admin}" CRYPTPASS=$(openssl passwd -apr1 "${NGX_PASS}") echo "${NGX_NAME}:${CRYPTPASS}" > /home/user/app/ngpasswd # ======================== # nginx config # ======================== COMMIT=$(cat /app/openvscode-server/product.json | awk '/commit/{print $4;exit}' FS='[""]') sed -i "s/#COMMIT#/$COMMIT/" /home/user/app/nginx.conf sed -i "s/#PORT#/${PORT:-8080}/" /home/user/app/nginx.conf echo "🌐 Starting nginx..." nginx -c /home/user/app/nginx.conf # ======================== # Optional repo clone # ======================== if [[ ! -z "$REPO" ]]; then dir=$(basename "$REPO" .git) if [ ! -d "$dir" ]; then echo "📦 Cloning repo..." git clone "$REPO" "$dir" fi fi git config --global http.postBuffer 524288000 # ======================== # AI Agent # ======================== if [ -f "/home/user/app/app/agent/agent.py" ]; then echo "🧠 Starting AI Agent..." python3 /home/user/app/app/agent/agent.py & elif [ -f "/home/user/app/agent/agent.py" ]; then echo "🧠 Starting AI Agent..." python3 /home/user/app/agent/agent.py & else echo "⚠️ agent.py not found" fi # ======================== # VSCode Server # ======================== VSCODE=/app/openvscode-server/bin/openvscode-server echo "🔌 Installing VSCode extensions..." $VSCODE --install-extension ms-toolsai.jupyter || true $VSCODE --install-extension ms-python.python || true echo "✅ Starting OpenVSCode Server..." exec $VSCODE \ --host 0.0.0.0 \ --port 5050 \ --without-connection-token