Docker Compose Setup Guide
Docker Compose Setup - OpenVSCode with PostgreSQL RAG
Section titled “Docker Compose Setup - OpenVSCode with PostgreSQL RAG”Date: November 18, 2025 Status: ✅ Production Ready with Environment Variables
Overview
Section titled “Overview”This setup uses Docker Compose to run:
- PostgreSQL with pgvector - Vector database for RAG embeddings
- OpenVSCode Server - Browser-based IDE with workspace-rag extension pre-installed
No hardcoded passwords! All sensitive configuration is managed via environment variables.
Quick Start
Section titled “Quick Start”1. Set Up Environment Variables
Section titled “1. Set Up Environment Variables”# Copy the example filecp .env.example .env
# Edit .env with your secure passwordnano .env # or use your preferred editorImportant: Set a secure password in .env:
POSTGRES_PASSWORD=your-secure-password-here2. Start the Stack
Section titled “2. Start the Stack”# Start all services in the backgrounddocker-compose up -d
# View logsdocker-compose logs -f
# Check statusdocker-compose ps3. Access the IDE
Section titled “3. Access the IDE”Open: http://localhost:3000The database connection is pre-configured - no manual setup required!
4. Test RAG Functionality
Section titled “4. Test RAG Functionality”- Open a workspace in the IDE (File → Open Folder)
- Press
Cmd+Shift+P(orCtrl+Shift+P) - Type: “Workspace RAG: Index Workspace”
- Wait for indexing to complete ✅
5. Verify Data
Section titled “5. Verify Data”# Connect to databasedocker-compose exec postgres psql -U postgres -d workspace_rag
# Inside psql:SELECT COUNT(*) FROM workspace_documents;\qConfiguration
Section titled “Configuration”Environment Variables (.env)
Section titled “Environment Variables (.env)”| Variable | Default | Description |
|---|---|---|
POSTGRES_USER | postgres | PostgreSQL username |
POSTGRES_PASSWORD | required | PostgreSQL password (set this!) |
POSTGRES_DB | workspace_rag | Database name |
POSTGRES_PORT | 5432 | PostgreSQL port on host |
OPENVSCODE_PORT | 3000 | OpenVSCode port on host |
Extension Configuration
Section titled “Extension Configuration”The workspace-rag extension uses these default values (from package.json):
{ "workspaceRag.pgHost": "postgres-pgvector", "workspaceRag.pgPort": 5432, "workspaceRag.pgDatabase": "workspace_rag", "workspaceRag.pgUser": "postgres", "workspaceRag.pgPassword": "password"}Note: The password in the extension must match POSTGRES_PASSWORD in your .env file for the default setup. For custom passwords, see Custom Configuration below.
File Structure
Section titled “File Structure”vibecode-webgui/├── docker-compose.yml # Service definitions├── .env # Your environment variables (gitignored)├── .env.example # Template for .env├── init-db.sql # Database initialization script└── DOCKER_COMPOSE_SETUP.md # This fileCommon Commands
Section titled “Common Commands”Start Services
Section titled “Start Services”# Start all servicesdocker-compose up -d
# Start specific servicedocker-compose up -d postgresdocker-compose up -d openvscodeStop Services
Section titled “Stop Services”# Stop all services (keeps data)docker-compose down
# Stop and remove volumes (deletes data)docker-compose down -vView Logs
Section titled “View Logs”# All servicesdocker-compose logs -f
# Specific servicedocker-compose logs -f postgresdocker-compose logs -f openvscodeRestart Services
Section titled “Restart Services”# Restart alldocker-compose restart
# Restart specific servicedocker-compose restart postgresDatabase Management
Section titled “Database Management”# Connect to databasedocker-compose exec postgres psql -U postgres -d workspace_rag
# Backup databasedocker-compose exec postgres pg_dump -U postgres workspace_rag > backup.sql
# Restore databasecat backup.sql | docker-compose exec -T postgres psql -U postgres -d workspace_rag
# Clear all datadocker-compose exec postgres psql -U postgres -d workspace_rag -c "TRUNCATE workspace_documents CASCADE;"Custom Configuration
Section titled “Custom Configuration”Using Different Database Password
Section titled “Using Different Database Password”If you want to use a password other than “password”:
-
Update .env:
Terminal window POSTGRES_PASSWORD=my-secure-password -
Update Extension (Option A - Rebuild Extension):
Edit
extensions/workspace-rag/package.json:"workspaceRag.pgPassword": {"default": "my-secure-password"}Then rebuild:
Terminal window cd extensions/workspace-ragnpm run packagenpx @vscode/vsce package# Copy to Docker build directorycp workspace-rag-0.1.0.vsix /tmp/openvscode-dockerfile/workspace-rag-1.0.0.vsix# Rebuild Docker imagecd /tmp/openvscode-dockerfiledocker build -t openvscode-with-rag:latest .# Restart servicesdocker-compose downdocker-compose up -d -
Update Extension (Option B - VS Code Settings):
After starting the IDE, manually configure via Settings UI:
- Press
Cmd+,(Settings) - Search: “workspace rag”
- Set “Pg Password” to your password
- Press
Using Custom Ports
Section titled “Using Custom Ports”Edit .env:
POSTGRES_PORT=5433 # PostgreSQL on host:5433OPENVSCODE_PORT=8080 # OpenVSCode on host:8080Then restart:
docker-compose downdocker-compose up -dHealthchecks
Section titled “Healthchecks”The postgres service includes a healthcheck to ensure it’s ready before openvscode starts:
healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 5s timeout: 5s retries: 5This prevents connection errors during startup.
Data Persistence
Section titled “Data Persistence”PostgreSQL data is stored in a Docker volume:
# List volumesdocker volume ls | grep workspace
# Inspect volumedocker volume inspect vibecode-webgui_postgres_data
# Backup volumedocker run --rm -v vibecode-webgui_postgres_data:/data -v $(pwd):/backup \ ubuntu tar czf /backup/postgres-backup.tar.gz /data
# Restore volumedocker run --rm -v vibecode-webgui_postgres_data:/data -v $(pwd):/backup \ ubuntu tar xzf /backup/postgres-backup.tar.gz -C /Troubleshooting
Section titled “Troubleshooting”Extension Still Shows ECONNREFUSED
Section titled “Extension Still Shows ECONNREFUSED”-
Check containers are running:
Terminal window docker-compose ps -
Check logs for errors:
Terminal window docker-compose logs postgres | grep -i errordocker-compose logs openvscode | grep -i error -
Verify network:
Terminal window docker-compose exec openvscode ping -c 2 postgres-pgvector -
Check extension is using correct password:
- Open IDE Settings (
Cmd+,) - Search “workspace rag”
- Verify password matches your
.envfile
- Open IDE Settings (
Database Connection Refused
Section titled “Database Connection Refused”# Check PostgreSQL is healthydocker-compose exec postgres pg_isready -U postgres
# Check password in .env matchescat .env | grep POSTGRES_PASSWORDPort Already in Use
Section titled “Port Already in Use”# Check what's using the portlsof -i :3000 # or :5432
# Use different port in .envOPENVSCODE_PORT=8080Production Deployment
Section titled “Production Deployment”Security Best Practices
Section titled “Security Best Practices”-
Use strong passwords:
Terminal window # Generate secure passwordopenssl rand -base64 32 -
Don’t expose PostgreSQL port:
Edit
docker-compose.yml, remove:ports:- "${POSTGRES_PORT:-5432}:5432" -
Use Docker secrets (Docker Swarm):
services:postgres:secrets:- postgres_passwordenvironment:POSTGRES_PASSWORD_FILE: /run/secrets/postgres_passwordsecrets:postgres_password:external: true -
Enable SSL for PostgreSQL:
Mount SSL certificates:
volumes:- ./ssl/server.crt:/var/lib/postgresql/server.crt:ro- ./ssl/server.key:/var/lib/postgresql/server.key:ro
Environment-Specific Configs
Section titled “Environment-Specific Configs”# Developmentdocker-compose -f docker-compose.yml up -d
# Productiondocker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
# Stagingdocker-compose -f docker-compose.yml -f docker-compose.staging.yml up -dRebuilding the Extension
Section titled “Rebuilding the Extension”If you modify the extension:
# 1. Build extensioncd extensions/workspace-ragnpm run packagenpx @vscode/vsce package
# 2. Copy VSIX to Docker build directorycp workspace-rag-0.1.0.vsix /tmp/openvscode-dockerfile/workspace-rag-1.0.0.vsix
# 3. Rebuild Docker imagecd /tmp/openvscode-dockerfiledocker build -t openvscode-with-rag:latest .
# 4. Recreate container with new imagedocker-compose up -d --force-recreate openvscodeSummary
Section titled “Summary”✅ No hardcoded passwords - All sensitive data in .env
✅ Automatic database initialization - Schema created on first run
✅ Health checks - Ensures services start in correct order
✅ Data persistence - PostgreSQL data survives container restarts
✅ Easy configuration - Change ports and settings via .env
✅ Production ready - Supports Docker secrets and SSL
Quick Start:
cp .env.example .envnano .env # Set POSTGRES_PASSWORDdocker-compose up -dopen http://localhost:3000Access: http://localhost:3000 Status: ✅ Ready to Use