# Docker Setup for WarpDrive

Multi-stage Docker image with WarpDrive proxy routing to Puma and Falcon backends.

## Quick Start

```bash
# Build and run with docker-compose
docker-compose up warpdrive

# Or build standalone
docker build -t warpdrive .
docker run -p 8080:80 warpdrive
```

## What's Inside

The container runs three services via supervisor:

1. **Puma** (port 3000) - Sync Ruby HTTP server
2. **Falcon** (port 3001) - Async Ruby HTTP server
3. **WarpDrive** (port 80) - Rust/Pingora proxy with routing

## Routing Configuration

Built-in routes (see `/etc/warpdrive.toml` in container):

```toml
# /puma/* routes strip /puma prefix
/puma/hello → Puma backend at /hello

# /falcon/* routes strip /falcon prefix
/falcon/world → Falcon backend at /world

# Everything else goes to Puma
/ → Puma backend
```

## Testing

```bash
# Start container
docker-compose up -d warpdrive

# Run tests
./test-docker.sh

# Manual tests
curl http://localhost:8080/              # → Puma
curl http://localhost:8080/puma/test     # → Puma with /test path
curl http://localhost:8080/falcon/test   # → Falcon with /test path
```

## Image Details

**Base images:**
- Stage 1 (builder): `rust:1.90-alpine` - Compiles WarpDrive
- Stage 2 (runtime): `ruby:3.4-alpine` - Final image with Puma/Falcon

**Size optimization:**
- 2-stage multi-stage build
- Alpine Linux base (~50MB smaller)
- Static musl linking for WarpDrive
- Dependency caching for faster rebuilds
- ~150MB final image

**Process management:**
- Supervisor runs all services
- Auto-restart on failures
- Logs to stdout/stderr

## Custom Configuration

Mount custom TOML config:

```bash
docker run -p 8080:80 \
  -v $(pwd)/my-config.toml:/etc/warpdrive.toml \
  warpdrive
```

## Health Checks

Container includes health check via curl:
```bash
docker ps  # Shows health status
```

Healthcheck queries WarpDrive on port 80 every 30s.
