Skip to main content

Local Preview Environments

Docker Compose-based previews running on the same machine as the daemon.

When to Use

  • Development: Quick local testing
  • CI/CD: Jenkins, GitHub Actions with Docker
  • Low resource needs: Small projects

For production-like testing, see Cloud Preview.

Configuration

# Set Docker Compose file
goblin pipeline config -p PROJECT --docker-compose docker-compose.yml

# Set preview web service (for setup commands)
goblin pipeline config -p PROJECT --config preview_web_service=web

# Set test URLs
goblin pipeline config -p PROJECT --test-urls "http://localhost:3000"

How It Works

Port Isolation

Each pipeline gets a unique port offset to avoid conflicts:

PipelineOriginal PortActual Port
ENG-12330003010
ENG-12430003020
ENG-12530003030

Goblin generates docker-compose.goblin.yml with remapped ports.

Creation Process

1. Generate port offset (hash-based, checks availability)
2. Create isolated compose file with unique ports
3. Clean up any existing containers with same name
4. Build images (optional)
5. Start services: docker compose -p goblin-ENG-123 up -d
6. Run setup commands (DB reset, fixtures)
7. Discover service URLs
8. Save to database

Service Discovery

Goblin auto-discovers running services:

{
"web": "http://localhost:3010",
"api": "http://localhost:8010",
"db": "localhost:5442"
}

Setup Commands

Configure commands to run after containers start:

goblin pipeline config -p PROJECT --config test_setup_commands="
python manage.py migrate
python manage.py loaddata fixtures/test.json
"

Default: Tries python manage.py reset_all if available.

Docker Compose Requirements

Your docker-compose.yml should expose ports normally:

services:
web:
build: .
ports:
- "3000:3000"

api:
build: ./api
ports:
- "8080:8080"

Goblin handles port remapping automatically.

CLI Commands

# List active previews
goblin preview list

# Get preview URLs
goblin preview urls ENG-123

# View logs
goblin preview logs ENG-123 -f

# Container status
goblin preview ps ENG-123

# Execute command
goblin preview exec ENG-123 web "python manage.py shell"

# Stop preview
goblin preview stop ENG-123

# Restart
goblin preview restart ENG-123

Troubleshooting

Port Conflicts

# Check what's using a port
lsof -i :3010

# Force cleanup
docker compose -p goblin-eng123 down -v --remove-orphans

View All Containers

docker ps --filter "name=goblin-preview"