mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-11 23:35:25 -05:00
feat(platform): Add GitHub Codespaces devcontainer for PR reviews
SECRT-1933 This adds a complete devcontainer configuration for the AutoGPT Platform, optimized for PR reviews in GitHub Codespaces. Features: - Docker-in-Docker for full compose support - Pre-installed Python 3.13, Node 21, pnpm, Poetry - Auto-start of all platform services (Supabase, Redis, RabbitMQ, etc.) - Pre-seeded test data with ready-to-use accounts - VS Code extensions for Python, TypeScript, Prisma, Playwright - Debug launch configs for backend and frontend - Optimized for prebuilds (~60s spinup vs 5-10 min) Test account: test123@gmail.com / testpassword123 Files: - .devcontainer/devcontainer.json - Main configuration - .devcontainer/docker-compose.devcontainer.yml - Compose overlay - .devcontainer/scripts/ - Lifecycle scripts (oncreate, postcreate, poststart) - .devcontainer/vscode-templates/ - Optional VS Code debug configs - .devcontainer/README.md - Documentation
This commit is contained in:
187
autogpt_platform/.devcontainer/README.md
Normal file
187
autogpt_platform/.devcontainer/README.md
Normal file
@@ -0,0 +1,187 @@
|
||||
# GitHub Codespaces for AutoGPT Platform
|
||||
|
||||
This dev container provides a complete development environment for the AutoGPT Platform, optimized for PR reviews.
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
1. **Open in Codespaces:**
|
||||
- Go to the repository on GitHub
|
||||
- Click **Code** → **Codespaces** → **Create codespace on dev**
|
||||
- Or click the badge: [](https://codespaces.new/Significant-Gravitas/AutoGPT?quickstart=1)
|
||||
|
||||
2. **Wait for setup** (~60 seconds with prebuild, ~5-10 min without)
|
||||
|
||||
3. **Start developing!**
|
||||
- Frontend auto-opens at `http://localhost:3000`
|
||||
- Login with: `test123@gmail.com` / `testpassword123`
|
||||
|
||||
## 📍 Available Services
|
||||
|
||||
| Service | URL | Notes |
|
||||
|---------|-----|-------|
|
||||
| Frontend | http://localhost:3000 | Next.js app |
|
||||
| REST API | http://localhost:8006 | FastAPI backend |
|
||||
| WebSocket | ws://localhost:8001 | Real-time updates |
|
||||
| Supabase | http://localhost:8000 | Auth & API gateway |
|
||||
| Supabase Studio | http://localhost:5555 | Database admin |
|
||||
| RabbitMQ | http://localhost:15672 | Queue management |
|
||||
|
||||
## 🔑 Test Accounts
|
||||
|
||||
| Email | Password | Role |
|
||||
|-------|----------|------|
|
||||
| test123@gmail.com | testpassword123 | Featured Creator |
|
||||
|
||||
The test account has:
|
||||
- Pre-created agents and workflows
|
||||
- Published store listings
|
||||
- Active agent executions
|
||||
- Reviews and ratings
|
||||
|
||||
## 🛠️ Development Commands
|
||||
|
||||
```bash
|
||||
# Navigate to platform directory (terminal starts here by default)
|
||||
cd autogpt_platform
|
||||
|
||||
# Start all services
|
||||
docker compose up -d
|
||||
|
||||
# Or just core services (DB, Redis, RabbitMQ)
|
||||
make start-core
|
||||
|
||||
# Run backend in dev mode (hot reload)
|
||||
make run-backend
|
||||
|
||||
# Run frontend in dev mode (hot reload)
|
||||
make run-frontend
|
||||
|
||||
# Run both backend and frontend
|
||||
# (Use VS Code's "Full Stack" launch config for debugging)
|
||||
|
||||
# Format code
|
||||
make format
|
||||
|
||||
# Run tests
|
||||
make test-data # Regenerate test data
|
||||
poetry run test # Backend tests (from backend/)
|
||||
pnpm test:e2e # E2E tests (from frontend/)
|
||||
```
|
||||
|
||||
## 🐛 Debugging
|
||||
|
||||
### VS Code Launch Configs
|
||||
|
||||
> **Note:** Launch and task configs are in `.devcontainer/vscode-templates/`.
|
||||
> To use them locally, copy to `.vscode/`:
|
||||
> ```bash
|
||||
> cp .devcontainer/vscode-templates/*.json .vscode/
|
||||
> ```
|
||||
> In Codespaces, core settings are auto-applied via devcontainer.json.
|
||||
|
||||
Press `F5` or use the Run and Debug panel:
|
||||
|
||||
- **Backend: Debug FastAPI** - Debug the REST API server
|
||||
- **Backend: Debug Executor** - Debug the agent executor
|
||||
- **Frontend: Debug Next.js** - Debug with browser DevTools
|
||||
- **Full Stack: Backend + Frontend** - Debug both simultaneously
|
||||
- **Tests: Run E2E Tests** - Run Playwright tests
|
||||
|
||||
### VS Code Tasks
|
||||
|
||||
Press `Ctrl+Shift+P` → "Tasks: Run Task":
|
||||
|
||||
- Start/Stop All Services
|
||||
- Run Migrations
|
||||
- Seed Test Data
|
||||
- View Docker Logs
|
||||
- Reset Database
|
||||
|
||||
## 📁 Project Structure
|
||||
|
||||
```
|
||||
autogpt_platform/ # This folder
|
||||
├── .devcontainer/ # Codespaces/devcontainer config
|
||||
├── .vscode/ # VS Code settings
|
||||
├── backend/ # Python FastAPI backend
|
||||
│ ├── backend/ # Application code
|
||||
│ ├── test/ # Test files + data seeders
|
||||
│ └── migrations/ # Prisma migrations
|
||||
├── frontend/ # Next.js frontend
|
||||
│ ├── src/ # Application code
|
||||
│ └── e2e/ # Playwright E2E tests
|
||||
├── db/ # Supabase configuration
|
||||
├── docker-compose.yml # Service orchestration
|
||||
└── Makefile # Common commands
|
||||
```
|
||||
|
||||
## 🔧 Troubleshooting
|
||||
|
||||
### Services not starting?
|
||||
```bash
|
||||
# Check service status
|
||||
docker compose ps
|
||||
|
||||
# View logs
|
||||
docker compose logs -f
|
||||
|
||||
# Restart everything
|
||||
docker compose down && docker compose up -d
|
||||
```
|
||||
|
||||
### Database issues?
|
||||
```bash
|
||||
# Reset database (destroys all data)
|
||||
make reset-db
|
||||
|
||||
# Re-run migrations
|
||||
make migrate
|
||||
|
||||
# Re-seed test data
|
||||
make test-data
|
||||
```
|
||||
|
||||
### Port already in use?
|
||||
```bash
|
||||
# Check what's using the port
|
||||
lsof -i :3000
|
||||
|
||||
# Kill process (if safe)
|
||||
kill -9 <PID>
|
||||
```
|
||||
|
||||
### Can't login?
|
||||
- Ensure all services are running: `docker compose ps`
|
||||
- Check auth service: `docker compose logs auth`
|
||||
- Try seeding data again: `make test-data`
|
||||
|
||||
## 📝 Making Changes
|
||||
|
||||
### Backend Changes
|
||||
1. Edit files in `backend/backend/`
|
||||
2. If using `make run-backend`, changes auto-reload
|
||||
3. Run `poetry run format` before committing
|
||||
|
||||
### Frontend Changes
|
||||
1. Edit files in `frontend/src/`
|
||||
2. If using `make run-frontend`, changes auto-reload
|
||||
3. Run `pnpm format` before committing
|
||||
|
||||
### Database Schema Changes
|
||||
1. Edit `backend/schema.prisma`
|
||||
2. Run `poetry run prisma migrate dev --name your_migration`
|
||||
3. Run `poetry run prisma generate`
|
||||
|
||||
## 🔒 Environment Variables
|
||||
|
||||
Default environment variables are configured for local development. For production secrets, use GitHub Codespaces Secrets:
|
||||
|
||||
1. Go to GitHub Settings → Codespaces → Secrets
|
||||
2. Add secrets with names matching `.env` variables
|
||||
3. They'll be automatically available in your codespace
|
||||
|
||||
## 📚 More Resources
|
||||
|
||||
- [AutoGPT Platform Docs](https://docs.agpt.co)
|
||||
- [Codespaces Documentation](https://docs.github.com/en/codespaces)
|
||||
- [Dev Containers Spec](https://containers.dev)
|
||||
158
autogpt_platform/.devcontainer/devcontainer.json
Normal file
158
autogpt_platform/.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,158 @@
|
||||
{
|
||||
"name": "AutoGPT Platform",
|
||||
"dockerComposeFile": [
|
||||
"../docker-compose.yml",
|
||||
"docker-compose.devcontainer.yml"
|
||||
],
|
||||
"service": "devcontainer",
|
||||
"workspaceFolder": "/workspaces/AutoGPT/autogpt_platform",
|
||||
"shutdownAction": "stopCompose",
|
||||
|
||||
// Features - Docker-in-Docker for full compose support
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/docker-in-docker:2": {
|
||||
"dockerDashComposeVersion": "v2"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/github-cli:1": {},
|
||||
"ghcr.io/devcontainers/features/node:1": {
|
||||
"version": "21",
|
||||
"nodeGypDependencies": true
|
||||
},
|
||||
"ghcr.io/devcontainers/features/python:1": {
|
||||
"version": "3.13",
|
||||
"installTools": true
|
||||
}
|
||||
},
|
||||
|
||||
// Lifecycle scripts
|
||||
// onCreateCommand runs during prebuild - do heavy lifting here
|
||||
"onCreateCommand": "bash .devcontainer/scripts/oncreate.sh",
|
||||
|
||||
// postCreateCommand runs after container creation - user-specific setup
|
||||
"postCreateCommand": "bash .devcontainer/scripts/postcreate.sh",
|
||||
|
||||
// postStartCommand runs every time the container starts (including resume)
|
||||
"postStartCommand": "bash .devcontainer/scripts/poststart.sh",
|
||||
|
||||
// Port forwarding
|
||||
"forwardPorts": [
|
||||
3000, // Frontend
|
||||
8006, // REST API
|
||||
8001, // WebSocket
|
||||
8000, // Supabase Kong
|
||||
5432, // PostgreSQL
|
||||
6379, // Redis
|
||||
15672, // RabbitMQ Management
|
||||
5555 // Supabase Studio
|
||||
],
|
||||
|
||||
"portsAttributes": {
|
||||
"3000": { "label": "Frontend", "onAutoForward": "openBrowser" },
|
||||
"8006": { "label": "REST API", "onAutoForward": "notify" },
|
||||
"8001": { "label": "WebSocket", "onAutoForward": "silent" },
|
||||
"8000": { "label": "Supabase", "onAutoForward": "silent" },
|
||||
"5432": { "label": "PostgreSQL", "onAutoForward": "silent" },
|
||||
"6379": { "label": "Redis", "onAutoForward": "silent" },
|
||||
"15672": { "label": "RabbitMQ", "onAutoForward": "silent" },
|
||||
"5555": { "label": "Supabase Studio", "onAutoForward": "silent" }
|
||||
},
|
||||
|
||||
// VS Code customizations
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"settings": {
|
||||
// Python
|
||||
"python.defaultInterpreterPath": "${workspaceFolder}/backend/.venv/bin/python",
|
||||
"python.analysis.typeCheckingMode": "basic",
|
||||
"python.testing.pytestEnabled": true,
|
||||
"python.testing.pytestArgs": ["backend"],
|
||||
|
||||
// Formatting
|
||||
"[python]": {
|
||||
"editor.defaultFormatter": "ms-python.black-formatter",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[typescript]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[typescriptreact]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"[javascript]": {
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
|
||||
// Editor
|
||||
"editor.rulers": [88, 120],
|
||||
"editor.tabSize": 2,
|
||||
"files.trimTrailingWhitespace": true,
|
||||
|
||||
// Terminal
|
||||
"terminal.integrated.defaultProfile.linux": "bash",
|
||||
"terminal.integrated.cwd": "${workspaceFolder}",
|
||||
|
||||
// Git
|
||||
"git.autofetch": true,
|
||||
"git.enableSmartCommit": true,
|
||||
|
||||
// Prisma
|
||||
"prisma.showPrismaDataPlatformNotification": false
|
||||
},
|
||||
|
||||
"extensions": [
|
||||
// Python
|
||||
"ms-python.python",
|
||||
"ms-python.vscode-pylance",
|
||||
"ms-python.black-formatter",
|
||||
"ms-python.isort",
|
||||
|
||||
// JavaScript/TypeScript
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"bradlc.vscode-tailwindcss",
|
||||
|
||||
// Database
|
||||
"Prisma.prisma",
|
||||
|
||||
// Testing
|
||||
"ms-playwright.playwright",
|
||||
|
||||
// GitHub
|
||||
"GitHub.vscode-pull-request-github",
|
||||
"GitHub.copilot",
|
||||
"github.vscode-github-actions",
|
||||
|
||||
// Utilities
|
||||
"eamodio.gitlens",
|
||||
"usernamehw.errorlens",
|
||||
"christian-kohler.path-intellisense",
|
||||
"mikestead.dotenv"
|
||||
]
|
||||
},
|
||||
|
||||
"codespaces": {
|
||||
"openFiles": [
|
||||
"README.md"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
// Environment variables
|
||||
"containerEnv": {
|
||||
"CODESPACES": "true",
|
||||
"POETRY_VIRTUALENVS_IN_PROJECT": "true"
|
||||
},
|
||||
|
||||
// Run as non-root for security
|
||||
"remoteUser": "vscode",
|
||||
|
||||
// Host requirements for performance
|
||||
"hostRequirements": {
|
||||
"cpus": 4,
|
||||
"memory": "8gb",
|
||||
"storage": "32gb"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
# Docker Compose override for dev container
|
||||
# This extends the main docker-compose.yml to add a dev container service
|
||||
|
||||
services:
|
||||
devcontainer:
|
||||
image: mcr.microsoft.com/devcontainers/base:ubuntu-24.04
|
||||
volumes:
|
||||
# Mount the entire AutoGPT repo (parent of autogpt_platform)
|
||||
- ../..:/workspaces/AutoGPT:cached
|
||||
# Docker-in-Docker socket
|
||||
- /var/run/docker.sock:/var/run/docker-host.sock
|
||||
|
||||
# Keep container running
|
||||
command: sleep infinity
|
||||
|
||||
# Use host network for easy access to other services
|
||||
network_mode: host
|
||||
|
||||
environment:
|
||||
# Codespaces detection
|
||||
- CODESPACES=true
|
||||
|
||||
# Database - use localhost (host network mode)
|
||||
- DATABASE_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@localhost:5432/postgres?schema=platform&connect_timeout=60
|
||||
- DIRECT_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@localhost:5432/postgres?schema=platform&connect_timeout=60
|
||||
- DB_HOST=localhost
|
||||
- DB_PORT=5432
|
||||
|
||||
# Redis
|
||||
- REDIS_HOST=localhost
|
||||
- REDIS_PORT=6379
|
||||
|
||||
# RabbitMQ
|
||||
- RABBITMQ_HOST=localhost
|
||||
|
||||
# Supabase
|
||||
- SUPABASE_URL=http://localhost:8000
|
||||
- SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q
|
||||
- JWT_VERIFY_KEY=your-super-secret-jwt-token-with-at-least-32-characters-long
|
||||
|
||||
# Frontend URLs (Codespaces will rewrite these)
|
||||
- NEXT_PUBLIC_SUPABASE_URL=http://localhost:8000
|
||||
- NEXT_PUBLIC_AGPT_SERVER_URL=http://localhost:8006/api
|
||||
- NEXT_PUBLIC_AGPT_WS_SERVER_URL=ws://localhost:8001/ws
|
||||
|
||||
# Backend URLs
|
||||
- PLATFORM_BASE_URL=http://localhost:8000
|
||||
- FRONTEND_BASE_URL=http://localhost:3000
|
||||
|
||||
# Disable telemetry in dev
|
||||
- NEXT_TELEMETRY_DISABLED=1
|
||||
- DO_NOT_TRACK=1
|
||||
|
||||
# Poetry
|
||||
- POETRY_VIRTUALENVS_IN_PROJECT=true
|
||||
- POETRY_NO_INTERACTION=1
|
||||
119
autogpt_platform/.devcontainer/scripts/oncreate.sh
Executable file
119
autogpt_platform/.devcontainer/scripts/oncreate.sh
Executable file
@@ -0,0 +1,119 @@
|
||||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# ONCREATE SCRIPT - Runs during prebuild
|
||||
# =============================================================================
|
||||
# This script is executed during the prebuild phase. Its job is to do all the
|
||||
# heavy lifting that takes time: installing dependencies, pulling Docker images,
|
||||
# generating code, etc. This makes codespace creation nearly instant.
|
||||
# =============================================================================
|
||||
|
||||
set -e # Exit on error
|
||||
set -x # Print commands for debugging
|
||||
|
||||
echo "🚀 Starting prebuild setup..."
|
||||
|
||||
# Workspace is autogpt_platform
|
||||
cd /workspaces/AutoGPT/autogpt_platform
|
||||
|
||||
# =============================================================================
|
||||
# Install Backend Dependencies
|
||||
# =============================================================================
|
||||
echo "📦 Installing backend dependencies..."
|
||||
|
||||
cd backend
|
||||
|
||||
# Install Poetry if not present
|
||||
if ! command -v poetry &> /dev/null; then
|
||||
echo "Installing Poetry..."
|
||||
curl -sSL https://install.python-poetry.org | python3 -
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
fi
|
||||
|
||||
# Install Python dependencies
|
||||
poetry install --no-interaction --no-ansi
|
||||
|
||||
# Generate Prisma client (can be done without DB)
|
||||
echo "🔧 Generating Prisma client..."
|
||||
poetry run prisma generate || true
|
||||
poetry run gen-prisma-stub || true
|
||||
|
||||
cd ..
|
||||
|
||||
# =============================================================================
|
||||
# Install Frontend Dependencies
|
||||
# =============================================================================
|
||||
echo "📦 Installing frontend dependencies..."
|
||||
|
||||
cd frontend
|
||||
|
||||
# Install pnpm if not present
|
||||
if ! command -v pnpm &> /dev/null; then
|
||||
echo "Installing pnpm..."
|
||||
npm install -g pnpm
|
||||
fi
|
||||
|
||||
# Install Node dependencies
|
||||
pnpm install --frozen-lockfile
|
||||
|
||||
# Generate API client types (if possible without backend running)
|
||||
pnpm generate:api-client || echo "API client generation skipped (backend not running)"
|
||||
|
||||
cd ..
|
||||
|
||||
# =============================================================================
|
||||
# Pull Docker Images (in parallel for speed)
|
||||
# =============================================================================
|
||||
echo "🐳 Pulling Docker images..."
|
||||
|
||||
# Start Docker daemon if using docker-in-docker
|
||||
if [ -e /var/run/docker-host.sock ]; then
|
||||
sudo ln -sf /var/run/docker-host.sock /var/run/docker.sock || true
|
||||
fi
|
||||
|
||||
# Pull images in parallel using background processes
|
||||
docker pull supabase/gotrue:v2.170.0 &
|
||||
docker pull supabase/studio:20250224-d10db0f &
|
||||
docker pull kong:2.8.1 &
|
||||
docker pull supabase/postgres:15.8.1.060 &
|
||||
docker pull redis:latest &
|
||||
docker pull rabbitmq:management &
|
||||
docker pull clamav/clamav-debian:latest &
|
||||
|
||||
# Wait for all pulls to complete
|
||||
wait
|
||||
|
||||
echo "✅ Docker images pulled"
|
||||
|
||||
# =============================================================================
|
||||
# Copy environment files
|
||||
# =============================================================================
|
||||
echo "📄 Setting up environment files..."
|
||||
|
||||
cd /workspaces/AutoGPT/autogpt_platform
|
||||
|
||||
# Backend
|
||||
if [ ! -f backend/.env ]; then
|
||||
cp backend/.env.default backend/.env
|
||||
fi
|
||||
|
||||
# Frontend
|
||||
if [ ! -f frontend/.env ]; then
|
||||
cp frontend/.env.default frontend/.env
|
||||
fi
|
||||
|
||||
# Platform root
|
||||
if [ ! -f .env ]; then
|
||||
cp .env.default .env
|
||||
fi
|
||||
|
||||
# =============================================================================
|
||||
# Done!
|
||||
# =============================================================================
|
||||
echo ""
|
||||
echo "=============================================="
|
||||
echo "✅ PREBUILD COMPLETE"
|
||||
echo "=============================================="
|
||||
echo ""
|
||||
echo "Dependencies installed, images pulled."
|
||||
echo "The postcreate script will start services."
|
||||
echo ""
|
||||
134
autogpt_platform/.devcontainer/scripts/postcreate.sh
Executable file
134
autogpt_platform/.devcontainer/scripts/postcreate.sh
Executable file
@@ -0,0 +1,134 @@
|
||||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# POSTCREATE SCRIPT - Runs after container creation
|
||||
# =============================================================================
|
||||
# This script runs once when a codespace is first created. It starts the
|
||||
# services, runs migrations, and seeds the database with test data.
|
||||
# =============================================================================
|
||||
|
||||
set -e # Exit on error
|
||||
|
||||
echo "🚀 Setting up your development environment..."
|
||||
|
||||
cd /workspaces/AutoGPT/autogpt_platform
|
||||
|
||||
# =============================================================================
|
||||
# Ensure Docker is available
|
||||
# =============================================================================
|
||||
if [ -e /var/run/docker-host.sock ]; then
|
||||
sudo ln -sf /var/run/docker-host.sock /var/run/docker.sock 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Wait for Docker to be ready
|
||||
echo "⏳ Waiting for Docker..."
|
||||
timeout 60 bash -c 'until docker info &>/dev/null; do sleep 1; done'
|
||||
echo "✅ Docker is ready"
|
||||
|
||||
# =============================================================================
|
||||
# Start Core Services
|
||||
# =============================================================================
|
||||
echo "🐳 Starting Docker services..."
|
||||
|
||||
# Start services (Supabase DB, Auth, Kong, Redis, RabbitMQ)
|
||||
docker compose up -d db redis rabbitmq kong auth
|
||||
|
||||
# Wait for PostgreSQL to be healthy
|
||||
echo "⏳ Waiting for PostgreSQL..."
|
||||
timeout 120 bash -c '
|
||||
until docker compose exec -T db pg_isready -U postgres &>/dev/null; do
|
||||
sleep 2
|
||||
echo " Waiting for database..."
|
||||
done
|
||||
'
|
||||
echo "✅ PostgreSQL is ready"
|
||||
|
||||
# Wait for other services
|
||||
echo "⏳ Waiting for Redis..."
|
||||
timeout 60 bash -c 'until docker compose exec -T redis redis-cli ping &>/dev/null; do sleep 1; done'
|
||||
echo "✅ Redis is ready"
|
||||
|
||||
echo "⏳ Waiting for RabbitMQ..."
|
||||
timeout 90 bash -c 'until docker compose exec -T rabbitmq rabbitmq-diagnostics -q ping &>/dev/null; do sleep 2; done'
|
||||
echo "✅ RabbitMQ is ready"
|
||||
|
||||
# =============================================================================
|
||||
# Run Database Migrations
|
||||
# =============================================================================
|
||||
echo "🔄 Running database migrations..."
|
||||
|
||||
cd backend
|
||||
|
||||
# Ensure Poetry is in PATH
|
||||
export PATH="$HOME/.local/bin:$PATH"
|
||||
|
||||
# Run migrations
|
||||
poetry run prisma migrate deploy
|
||||
poetry run prisma generate
|
||||
poetry run gen-prisma-stub || true
|
||||
|
||||
cd ..
|
||||
|
||||
# =============================================================================
|
||||
# Seed Test Data
|
||||
# =============================================================================
|
||||
echo "🌱 Seeding test data..."
|
||||
|
||||
cd backend
|
||||
|
||||
# Check if test data already exists (idempotent)
|
||||
if poetry run python -c "
|
||||
import asyncio
|
||||
from backend.data.db import prisma
|
||||
|
||||
async def check():
|
||||
await prisma.connect()
|
||||
count = await prisma.user.count()
|
||||
await prisma.disconnect()
|
||||
return count > 0
|
||||
|
||||
print('exists' if asyncio.run(check()) else 'empty')
|
||||
" 2>/dev/null | grep -q "exists"; then
|
||||
echo " Test data already exists, skipping seed"
|
||||
else
|
||||
echo " Running E2E test data creator..."
|
||||
poetry run python test/e2e_test_data.py || echo "⚠️ Test data seeding had issues (may be partial)"
|
||||
fi
|
||||
|
||||
cd ..
|
||||
|
||||
# =============================================================================
|
||||
# Start Backend Services (optional - for immediate use)
|
||||
# =============================================================================
|
||||
echo "🚀 Starting backend services..."
|
||||
|
||||
# Start remaining services
|
||||
docker compose up -d migrate
|
||||
sleep 5 # Wait for migration container
|
||||
|
||||
docker compose up -d rest_server executor websocket_server database_manager
|
||||
|
||||
# =============================================================================
|
||||
# Print Welcome Message
|
||||
# =============================================================================
|
||||
echo ""
|
||||
echo "=============================================="
|
||||
echo "🎉 CODESPACE READY!"
|
||||
echo "=============================================="
|
||||
echo ""
|
||||
echo "📍 Quick Links (will auto-forward):"
|
||||
echo " Frontend: http://localhost:3000"
|
||||
echo " API: http://localhost:8006"
|
||||
echo " Supabase: http://localhost:8000"
|
||||
echo ""
|
||||
echo "🔑 Test Account:"
|
||||
echo " Email: test123@gmail.com"
|
||||
echo " Password: testpassword123"
|
||||
echo ""
|
||||
echo "🛠️ Development Commands:"
|
||||
echo " make run-frontend # Start frontend dev server"
|
||||
echo " make run-backend # Start backend dev server"
|
||||
echo " make start-core # Start only core services"
|
||||
echo " make test-data # Regenerate test data"
|
||||
echo ""
|
||||
echo "📚 See README.md for more info"
|
||||
echo ""
|
||||
43
autogpt_platform/.devcontainer/scripts/poststart.sh
Executable file
43
autogpt_platform/.devcontainer/scripts/poststart.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
# =============================================================================
|
||||
# POSTSTART SCRIPT - Runs every time the codespace starts
|
||||
# =============================================================================
|
||||
# This script runs when:
|
||||
# 1. Codespace is first created (after postcreate)
|
||||
# 2. Codespace resumes from stopped state
|
||||
# 3. Codespace rebuilds
|
||||
#
|
||||
# It ensures services are running without doing heavy setup work.
|
||||
# =============================================================================
|
||||
|
||||
echo "🔄 Starting services..."
|
||||
|
||||
cd /workspaces/AutoGPT/autogpt_platform
|
||||
|
||||
# Ensure Docker socket is available
|
||||
if [ -e /var/run/docker-host.sock ]; then
|
||||
sudo ln -sf /var/run/docker-host.sock /var/run/docker.sock 2>/dev/null || true
|
||||
fi
|
||||
|
||||
# Wait for Docker
|
||||
timeout 30 bash -c 'until docker info &>/dev/null; do sleep 1; done' || {
|
||||
echo "⚠️ Docker not available, services may need manual start"
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Start all services (will be no-op for already running ones)
|
||||
docker compose up -d
|
||||
|
||||
# Quick health check
|
||||
echo "⏳ Waiting for services..."
|
||||
sleep 5
|
||||
|
||||
# Check if key services are running
|
||||
if docker compose ps | grep -q "running"; then
|
||||
echo "✅ Services are running"
|
||||
echo ""
|
||||
echo "📍 Frontend: http://localhost:3000"
|
||||
echo "📍 API: http://localhost:8006"
|
||||
else
|
||||
echo "⚠️ Some services may not be running. Try: docker compose up -d"
|
||||
fi
|
||||
107
autogpt_platform/.devcontainer/vscode-templates/launch.json
Normal file
107
autogpt_platform/.devcontainer/vscode-templates/launch.json
Normal file
@@ -0,0 +1,107 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Backend: Debug FastAPI",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"module": "uvicorn",
|
||||
"args": [
|
||||
"backend.rest:app",
|
||||
"--reload",
|
||||
"--host", "0.0.0.0",
|
||||
"--port", "8006"
|
||||
],
|
||||
"cwd": "${workspaceFolder}/backend",
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder}/backend"
|
||||
},
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false
|
||||
},
|
||||
{
|
||||
"name": "Backend: Debug Executor",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"module": "backend.exec",
|
||||
"cwd": "${workspaceFolder}/backend",
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder}/backend"
|
||||
},
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false
|
||||
},
|
||||
{
|
||||
"name": "Backend: Debug WebSocket",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"module": "backend.ws",
|
||||
"cwd": "${workspaceFolder}/backend",
|
||||
"env": {
|
||||
"PYTHONPATH": "${workspaceFolder}/backend"
|
||||
},
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false
|
||||
},
|
||||
{
|
||||
"name": "Frontend: Debug Next.js",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "pnpm",
|
||||
"runtimeArgs": ["dev"],
|
||||
"cwd": "${workspaceFolder}/frontend",
|
||||
"console": "integratedTerminal",
|
||||
"serverReadyAction": {
|
||||
"pattern": "- Local:.+(https?://\\S+)",
|
||||
"uriFormat": "%s",
|
||||
"action": "openExternally"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "Frontend: Debug Next.js (Server-side)",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "pnpm",
|
||||
"runtimeArgs": ["dev"],
|
||||
"cwd": "${workspaceFolder}/frontend",
|
||||
"env": {
|
||||
"NODE_OPTIONS": "--inspect"
|
||||
},
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
{
|
||||
"name": "Tests: Run Backend Tests",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"module": "pytest",
|
||||
"args": ["-v", "--tb=short"],
|
||||
"cwd": "${workspaceFolder}/backend",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": false
|
||||
},
|
||||
{
|
||||
"name": "Tests: Run E2E Tests (Playwright)",
|
||||
"type": "node",
|
||||
"request": "launch",
|
||||
"runtimeExecutable": "pnpm",
|
||||
"runtimeArgs": ["test:e2e"],
|
||||
"cwd": "${workspaceFolder}/frontend",
|
||||
"console": "integratedTerminal"
|
||||
},
|
||||
{
|
||||
"name": "Scripts: Seed Test Data",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/backend/test/e2e_test_data.py",
|
||||
"cwd": "${workspaceFolder}/backend",
|
||||
"console": "integratedTerminal"
|
||||
}
|
||||
],
|
||||
"compounds": [
|
||||
{
|
||||
"name": "Full Stack: Backend + Frontend",
|
||||
"configurations": ["Backend: Debug FastAPI", "Frontend: Debug Next.js"],
|
||||
"stopAll": true
|
||||
}
|
||||
]
|
||||
}
|
||||
147
autogpt_platform/.devcontainer/vscode-templates/tasks.json
Normal file
147
autogpt_platform/.devcontainer/vscode-templates/tasks.json
Normal file
@@ -0,0 +1,147 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Start All Services",
|
||||
"type": "shell",
|
||||
"command": "docker compose up -d",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "Stop All Services",
|
||||
"type": "shell",
|
||||
"command": "docker compose stop",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Start Core Services",
|
||||
"type": "shell",
|
||||
"command": "make start-core",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"group": "build"
|
||||
},
|
||||
{
|
||||
"label": "Run Backend (Dev Mode)",
|
||||
"type": "shell",
|
||||
"command": "poetry run app",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/backend"
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"isBackground": true,
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Run Frontend (Dev Mode)",
|
||||
"type": "shell",
|
||||
"command": "pnpm dev",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/frontend"
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"isBackground": true,
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Run Migrations",
|
||||
"type": "shell",
|
||||
"command": "make migrate",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Seed Test Data",
|
||||
"type": "shell",
|
||||
"command": "make test-data",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Format Code",
|
||||
"type": "shell",
|
||||
"command": "make format",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Backend: Run Tests",
|
||||
"type": "shell",
|
||||
"command": "poetry run test",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/backend"
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"group": "test"
|
||||
},
|
||||
{
|
||||
"label": "Frontend: Run Tests",
|
||||
"type": "shell",
|
||||
"command": "pnpm test",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/frontend"
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"group": "test"
|
||||
},
|
||||
{
|
||||
"label": "Frontend: Run E2E Tests",
|
||||
"type": "shell",
|
||||
"command": "pnpm test:e2e",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/frontend"
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"group": "test"
|
||||
},
|
||||
{
|
||||
"label": "Generate API Client",
|
||||
"type": "shell",
|
||||
"command": "pnpm generate:api",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/frontend"
|
||||
},
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "View Docker Logs",
|
||||
"type": "shell",
|
||||
"command": "docker compose logs -f",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": [],
|
||||
"isBackground": true
|
||||
},
|
||||
{
|
||||
"label": "Reset Database",
|
||||
"type": "shell",
|
||||
"command": "make reset-db",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user