Skip to main content

Docker Deployment

Comprehensive guide for deploying CoW Protocol BFF services using Docker and Docker Compose.

Service Architecture

The BFF comprises seven containerized services:

Building Images

Services utilize NX build targets with multi-stage Dockerfiles based on Alpine Linux:
All services use a similar multi-stage Dockerfile pattern:
  • Based on Alpine Linux with Node.js LTS
  • Non-root users for enhanced security
  • Production dependencies from built artifacts

Local Development

Environment Setup

Service Dependencies

The Docker Compose configuration defines service dependencies, ensuring proper startup sequencing. For example, the API service depends on the database being available first.

Production Deployment

Building for Production

Multi-Platform Builds

Most services specify platform: linux/amd64, though the queue service omits this for Apple Silicon support.

Running Migrations

Run migrations before deploying new versions:

Resource Requirements

Minimum Deployment

Total recommended: ~10GB RAM across services for optimal performance.

Health Monitoring

  • RabbitMQ and Redis: Built-in health checks with 30-second intervals
  • API: Exposes status information at the /about endpoint

Data Persistence

Three named volumes maintain state across container restarts:
  • data-postgres - Database storage
  • data-rabbitmq - Message queue state
  • data-redis - Cache data

Database Backup/Restore

Troubleshooting

Port Conflicts

Modify port mappings in docker-compose.yml if ports are already in use:

Permission Errors

Ensure Docker has proper file system permissions. On Linux, you may need to adjust volume ownership.

Startup Failures

Database connection errors typically require ensuring PostgreSQL initialization completes before dependent services start:

Container Shell Access

Full Reset

Last modified on March 4, 2026