mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
## Summary This PR adds the frontend service to the Docker Compose configuration, enabling `docker compose up` to run the complete stack including the frontend. It also implements comprehensive environment variable improvements and fixes Docker networking issues. ## Key Changes ### 🐳 Docker Compose Improvements - **Added frontend service** to `docker-compose.yml` and `docker-compose.platform.yml` - **Production build**: Uses `pnpm build + serve` instead of dev server for better stability and lower memory usage - **Service dependencies**: Frontend now waits for backend services (`rest_server`, `websocket_server`) to be ready - **YAML anchors**: Implemented DRY configuration to avoid duplicating environment values ### 🔧 Environment Variable Architecture - **Dual environment strategy**: - Server-side code uses Docker service names (`http://rest_server:8006/api`) - Client-side code uses localhost URLs (`http://localhost:8006/api`) - **Comprehensive config**: Added build args and runtime environment variables - **Network compatibility**: Fixes connection issues between frontend and backend containers ### 🛠️ Code Improvements - **Centralized env-config helper** (`/frontend/src/lib/env-config.ts`) with server-side priority - **Updated all frontend code** to use shared environment helpers instead of direct `process.env` access - **Consistent API**: All environment variable access now goes through helper functions ### 🔗 Files Changed - `docker-compose.yml` & `docker-compose.platform.yml` - Added frontend service - `frontend/Dockerfile` - Added build args for environment variables - `frontend/src/lib/env-config.ts` - New centralized environment configuration - Multiple frontend files - Updated to use env helpers ## Benefits - ✅ **Single command deployment**: `docker compose up` now runs everything - ✅ **Better reliability**: Production build reduces memory usage and crashes - ✅ **Network compatibility**: Proper container-to-container communication - ✅ **Maintainable config**: Centralized environment variable management - ✅ **Development friendly**: Works in both Docker and local development ## Testing - ✅ Verified Docker service communication works correctly - ✅ Frontend responds and serves content properly - ✅ Environment variables are correctly resolved in both server and client contexts - ✅ No connection errors after implementing service dependencies 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <noreply@anthropic.com>
324 lines
11 KiB
YAML
324 lines
11 KiB
YAML
services:
|
|
migrate:
|
|
build:
|
|
context: ../
|
|
dockerfile: autogpt_platform/backend/Dockerfile
|
|
target: server
|
|
command: ["sh", "-c", "poetry run prisma migrate deploy"]
|
|
develop:
|
|
watch:
|
|
- path: ./
|
|
target: autogpt_platform/backend/migrations
|
|
action: rebuild
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
environment:
|
|
- DATABASE_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
|
|
- DIRECT_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
|
|
networks:
|
|
- app-network
|
|
restart: on-failure
|
|
healthcheck:
|
|
test: ["CMD", "poetry", "run", "prisma", "migrate", "status"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
|
|
redis:
|
|
image: redis:latest
|
|
command: redis-server --requirepass password
|
|
ports:
|
|
- "6379:6379"
|
|
networks:
|
|
- app-network
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
rabbitmq:
|
|
image: rabbitmq:management
|
|
container_name: rabbitmq
|
|
healthcheck:
|
|
test: rabbitmq-diagnostics -q ping
|
|
interval: 30s
|
|
timeout: 10s
|
|
retries: 5
|
|
start_period: 10s
|
|
environment:
|
|
- RABBITMQ_DEFAULT_USER=rabbitmq_user_default
|
|
- RABBITMQ_DEFAULT_PASS=k0VMxyIJF9S35f3x2uaw5IWAl6Y536O7 # CHANGE THIS TO A RANDOM PASSWORD IN PRODUCTION -- everywhere lol
|
|
ports:
|
|
- "5672:5672"
|
|
- "15672:15672"
|
|
|
|
rest_server:
|
|
build:
|
|
context: ../
|
|
dockerfile: autogpt_platform/backend/Dockerfile
|
|
target: server
|
|
command: ["python", "-m", "backend.rest"]
|
|
develop:
|
|
watch:
|
|
- path: ./
|
|
target: autogpt_platform/backend/
|
|
action: rebuild
|
|
depends_on:
|
|
redis:
|
|
condition: service_healthy
|
|
db:
|
|
condition: service_healthy
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
rabbitmq:
|
|
condition: service_healthy
|
|
# scheduler_server:
|
|
# condition: service_healthy
|
|
environment:
|
|
- SUPABASE_URL=http://kong:8000
|
|
- SUPABASE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long
|
|
- SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q
|
|
- DATABASE_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
|
|
- DIRECT_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
|
|
- REDIS_HOST=redis
|
|
- REDIS_PORT=6379
|
|
- RABBITMQ_HOST=rabbitmq
|
|
- RABBITMQ_PORT=5672
|
|
- RABBITMQ_DEFAULT_USER=rabbitmq_user_default
|
|
- RABBITMQ_DEFAULT_PASS=k0VMxyIJF9S35f3x2uaw5IWAl6Y536O7
|
|
- REDIS_PASSWORD=password
|
|
- ENABLE_AUTH=true
|
|
- PYRO_HOST=0.0.0.0
|
|
- SCHEDULER_HOST=scheduler_server
|
|
- EXECUTIONMANAGER_HOST=executor
|
|
- NOTIFICATIONMANAGER_HOST=rest_server
|
|
- CLAMAV_SERVICE_HOST=clamav
|
|
- NEXT_PUBLIC_FRONTEND_BASE_URL=http://localhost:3000
|
|
- BACKEND_CORS_ALLOW_ORIGINS=["http://localhost:3000"]
|
|
- ENCRYPTION_KEY=dvziYgz0KSK8FENhju0ZYi8-fRTfAdlz6YLhdB_jhNw= # DO NOT USE IN PRODUCTION!!
|
|
- UNSUBSCRIBE_SECRET_KEY=HlP8ivStJjmbf6NKi78m_3FnOogut0t5ckzjsIqeaio= # DO NOT USE IN PRODUCTION!!
|
|
ports:
|
|
- "8006:8006"
|
|
- "8007:8007"
|
|
networks:
|
|
- app-network
|
|
|
|
executor:
|
|
build:
|
|
context: ../
|
|
dockerfile: autogpt_platform/backend/Dockerfile
|
|
target: server
|
|
command: ["python", "-m", "backend.exec"]
|
|
develop:
|
|
watch:
|
|
- path: ./
|
|
target: autogpt_platform/backend/
|
|
action: rebuild
|
|
depends_on:
|
|
redis:
|
|
condition: service_healthy
|
|
rabbitmq:
|
|
condition: service_healthy
|
|
db:
|
|
condition: service_healthy
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
database_manager:
|
|
condition: service_started
|
|
environment:
|
|
- DATABASEMANAGER_HOST=database_manager
|
|
- SUPABASE_URL=http://kong:8000
|
|
- SUPABASE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long
|
|
- SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJzZXJ2aWNlX3JvbGUiLAogICAgImlzcyI6ICJzdXBhYmFzZS1kZW1vIiwKICAgICJpYXQiOiAxNjQxNzY5MjAwLAogICAgImV4cCI6IDE3OTk1MzU2MDAKfQ.DaYlNEoUrrEn2Ig7tqibS-PHK5vgusbcbo7X36XVt4Q
|
|
- DATABASE_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
|
|
- DIRECT_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
|
|
- REDIS_HOST=redis
|
|
- REDIS_PORT=6379
|
|
- REDIS_PASSWORD=password
|
|
- RABBITMQ_HOST=rabbitmq
|
|
- RABBITMQ_PORT=5672
|
|
- RABBITMQ_DEFAULT_USER=rabbitmq_user_default
|
|
- RABBITMQ_DEFAULT_PASS=k0VMxyIJF9S35f3x2uaw5IWAl6Y536O7
|
|
- ENABLE_AUTH=true
|
|
- PYRO_HOST=0.0.0.0
|
|
- AGENTSERVER_HOST=rest_server
|
|
- NOTIFICATIONMANAGER_HOST=rest_server
|
|
- CLAMAV_SERVICE_HOST=clamav
|
|
- ENCRYPTION_KEY=dvziYgz0KSK8FENhju0ZYi8-fRTfAdlz6YLhdB_jhNw= # DO NOT USE IN PRODUCTION!!
|
|
ports:
|
|
- "8002:8002"
|
|
networks:
|
|
- app-network
|
|
|
|
websocket_server:
|
|
build:
|
|
context: ../
|
|
dockerfile: autogpt_platform/backend/Dockerfile
|
|
target: server
|
|
command: ["python", "-m", "backend.ws"]
|
|
develop:
|
|
watch:
|
|
- path: ./
|
|
target: autogpt_platform/backend/
|
|
action: rebuild
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
# rabbitmq:
|
|
# condition: service_healthy
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
database_manager:
|
|
condition: service_started
|
|
environment:
|
|
- DATABASEMANAGER_HOST=database_manager
|
|
- SUPABASE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long
|
|
- DATABASE_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
|
|
- DIRECT_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
|
|
- REDIS_HOST=redis
|
|
- REDIS_PORT=6379
|
|
- REDIS_PASSWORD=password
|
|
# - RABBITMQ_HOST=rabbitmq
|
|
# - RABBITMQ_PORT=5672
|
|
# - RABBITMQ_DEFAULT_USER=rabbitmq_user_default
|
|
# - RABBITMQ_DEFAULT_PASS=k0VMxyIJF9S35f3x2uaw5IWAl6Y536O7
|
|
- ENABLE_AUTH=true
|
|
- PYRO_HOST=0.0.0.0
|
|
- BACKEND_CORS_ALLOW_ORIGINS=["http://localhost:3000"]
|
|
|
|
ports:
|
|
- "8001:8001"
|
|
networks:
|
|
- app-network
|
|
|
|
database_manager:
|
|
build:
|
|
context: ../
|
|
dockerfile: autogpt_platform/backend/Dockerfile
|
|
target: server
|
|
command: ["python", "-m", "backend.db"]
|
|
develop:
|
|
watch:
|
|
- path: ./
|
|
target: autogpt_platform/backend/
|
|
action: rebuild
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
environment:
|
|
- DATABASE_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
|
|
- DIRECT_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
|
|
- PYRO_HOST=0.0.0.0
|
|
- ENCRYPTION_KEY=dvziYgz0KSK8FENhju0ZYi8-fRTfAdlz6YLhdB_jhNw= # DO NOT USE IN PRODUCTION!!
|
|
ports:
|
|
- "8005:8005"
|
|
networks:
|
|
- app-network
|
|
|
|
scheduler_server:
|
|
build:
|
|
context: ../
|
|
dockerfile: autogpt_platform/backend/Dockerfile
|
|
target: server
|
|
command: ["python", "-m", "backend.scheduler"]
|
|
develop:
|
|
watch:
|
|
- path: ./
|
|
target: autogpt_platform/backend/
|
|
action: rebuild
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
redis:
|
|
condition: service_healthy
|
|
rabbitmq:
|
|
condition: service_healthy
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
database_manager:
|
|
condition: service_started
|
|
# healthcheck:
|
|
# test:
|
|
# [
|
|
# "CMD",
|
|
# "curl",
|
|
# "-f",
|
|
# "-X",
|
|
# "POST",
|
|
# "http://localhost:8003/health_check",
|
|
# ]
|
|
# interval: 10s
|
|
# timeout: 10s
|
|
# retries: 5
|
|
environment:
|
|
- DATABASEMANAGER_HOST=database_manager
|
|
- NOTIFICATIONMANAGER_HOST=rest_server
|
|
- SUPABASE_JWT_SECRET=your-super-secret-jwt-token-with-at-least-32-characters-long
|
|
- DATABASE_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
|
|
- DIRECT_URL=postgresql://postgres:your-super-secret-and-long-postgres-password@db:5432/postgres?connect_timeout=60&schema=platform
|
|
- REDIS_HOST=redis
|
|
- REDIS_PORT=6379
|
|
- REDIS_PASSWORD=password
|
|
- RABBITMQ_HOST=rabbitmq
|
|
- RABBITMQ_PORT=5672
|
|
- RABBITMQ_DEFAULT_USER=rabbitmq_user_default
|
|
- RABBITMQ_DEFAULT_PASS=k0VMxyIJF9S35f3x2uaw5IWAl6Y536O7
|
|
- ENABLE_AUTH=true
|
|
- PYRO_HOST=0.0.0.0
|
|
- BACKEND_CORS_ALLOW_ORIGINS=["http://localhost:3000"]
|
|
|
|
ports:
|
|
- "8003:8003"
|
|
networks:
|
|
- app-network
|
|
|
|
# Frontend environment variables
|
|
x-frontend-vars: &frontend-vars
|
|
NEXT_PUBLIC_SUPABASE_URL: http://localhost:8000
|
|
NEXT_PUBLIC_SUPABASE_ANON_KEY: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyAgCiAgICAicm9sZSI6ICJhbm9uIiwKICAgICJpc3MiOiAic3VwYWJhc2UtZGVtbyIsCiAgICAiaWF0IjogMTY0MTc2OTIwMCwKICAgICJleHAiOiAxNzk5NTM1NjAwCn0.dc_X5iR_VP_qT0zsiyj_I_OZ2T9FtRU2BBNWN8Bu4GE
|
|
NEXT_PUBLIC_AGPT_SERVER_URL: http://localhost:8006/api
|
|
NEXT_PUBLIC_AGPT_WS_SERVER_URL: ws://localhost:8001/ws
|
|
NEXT_PUBLIC_FRONTEND_BASE_URL: http://localhost:3000
|
|
NEXT_PUBLIC_BEHAVE_AS: LOCAL
|
|
NEXT_PUBLIC_LAUNCHDARKLY_ENABLED: false
|
|
NEXT_PUBLIC_LAUNCHDARKLY_CLIENT_ID: 687ab1372f497809b131e06e
|
|
NEXT_PUBLIC_APP_ENV: local
|
|
NEXT_PUBLIC_DEFAULT_LOCALE: en
|
|
NEXT_PUBLIC_LOCALES: en,es
|
|
NEXT_PUBLIC_SHOW_BILLING_PAGE: false
|
|
NEXT_PUBLIC_TURNSTILE: disabled
|
|
NEXT_PUBLIC_REACT_QUERY_DEVTOOL: true
|
|
NEXT_PUBLIC_GA_MEASUREMENT_ID: G-FH2XK2W4GN
|
|
NEXT_PUBLIC_PW_TEST: "${NEXT_PUBLIC_PW_TEST:-}"
|
|
|
|
frontend:
|
|
build:
|
|
context: ../
|
|
dockerfile: autogpt_platform/frontend/Dockerfile
|
|
target: prod
|
|
args: *frontend-vars
|
|
depends_on:
|
|
db:
|
|
condition: service_healthy
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
ports:
|
|
- "3000:3000"
|
|
networks:
|
|
- app-network
|
|
environment:
|
|
<<: *frontend-vars
|
|
# Server-side environment variables (Docker service names)
|
|
AUTH_CALLBACK_URL: http://rest_server:8006/auth/callback
|
|
SUPABASE_URL: http://kong:8000
|
|
AGPT_SERVER_URL: http://rest_server:8006/api
|
|
AGPT_WS_SERVER_URL: ws://websocket_server:8001/ws
|
|
networks:
|
|
app-network:
|
|
driver: bridge
|