Spaces:
Sleeping
Sleeping
File size: 1,926 Bytes
819ff17 b422b4b 33e6e72 b422b4b 1aa4049 9185003 33e6e72 9dc479e b422b4b 9dc479e b422b4b 33e6e72 b422b4b 33e6e72 15c36d3 b422b4b 33e6e72 b422b4b def9b9a b422b4b 33e6e72 7facd24 e251c22 11fb7d6 7facd24 47a0d84 33e6e72 47a0d84 33e6e72 47a0d84 33e6e72 47a0d84 b422b4b 33e6e72 b422b4b 33e6e72 b422b4b 33e6e72 b422b4b 33e6e72 b422b4b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | #!/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 |