Skip to content

Docker Deployment

Hydra can be deployed using Docker for consistent, reproducible environments across development, staging, and production.

Terminal window
# Build the image
docker build -t hydra .
# Run paper trading
docker run --rm -v $(pwd)/config.yaml:/app/config.yaml:ro hydra
# Run live trading (requires secrets)
docker run --rm \
-v $(pwd)/config.yaml:/app/config.yaml:ro \
-e POLYMARKET_PRIVATE_KEY="your-key" \
hydra hydra run --mode live

For persistent deployments, use Docker Compose:

Terminal window
# Copy example config
cp config.example.yaml config.yaml
# Set your secrets in .env
echo "POLYMARKET_PRIVATE_KEY=your-key" > .env
# Run live trading
docker compose up -d hydra
# Run paper trading
docker compose --profile paper up -d hydra-paper
# View logs
docker compose logs -f hydra
# Stop
docker compose down
ServicePortDescription
hydra8787Main trading bot (live mode)
hydra-paper8788Paper trading (profile: paper)

Note: These are Docker Compose service names, not CLI commands. Inside containers, use hydra run or bun run paper.

PathDescription
/app/config.yamlConfiguration file (read-only)
/app/runsSession logs and artifacts
VariableRequiredDescription
POLYMARKET_PRIVATE_KEYLive onlyWallet private key
POLYMARKET_API_KEYLive onlyAPI key
POLYMARKET_API_SECRETLive onlyAPI secret
POLYMARKET_PASSPHRASELive onlyAPI passphrase
BOT_CONFIGNoConfig file path (default: /app/config.yaml)
NODE_ENVNoEnvironment (default: production)

The container includes a health check that polls http://localhost:8787/health every 30 seconds.

Terminal window
# Check container health
docker inspect --format='{{.State.Health.Status}}' hydra-bot
Terminal window
# Build with specific tag
docker build -t hydra:v1.0.0 .
# Push to registry
docker tag hydra:v1.0.0 your-registry.com/hydra:v1.0.0
docker push your-registry.com/hydra:v1.0.0

For production deployments, set resource limits:

services:
hydra:
deploy:
resources:
limits:
cpus: '2'
memory: 1G
reservations:
cpus: '0.5'
memory: 256M

Check logs for startup errors:

Terminal window
docker compose logs hydra

Common causes:

  • Invalid config.yaml syntax
  • Missing required environment variables
  • Config file not mounted correctly

Ensure port 8787 is exposed and not blocked by firewall:

Terminal window
docker compose port hydra 8787

Ensure the runs directory exists and has correct permissions:

Terminal window
mkdir -p runs
chmod 755 runs