> ## Documentation Index
> Fetch the complete documentation index at: https://docs.gorules.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Docker Compose

> Deploy GoRules BRMS with Docker Compose for development and small-scale production.

Docker Compose provides the simplest way to run GoRules BRMS with a PostgreSQL database.

## Prerequisites

* Docker installed
* Docker Compose v2+

## Quick start

Create a `docker-compose.yml` file:

```yaml theme={null}
version: '3.8'

services:
  brms:
    image: gorules/brms
    ports:
      - '9080:80'
    depends_on:
      - postgres
    environment:
      DB_HOST: postgres
      DB_PORT: 5432
      DB_USER: gorules
      DB_PASSWORD: your-secure-password
      DB_NAME: gorules
      DB_SSL_DISABLED: true
      LICENSE_KEY: your-license-key

  postgres:
    image: postgres:15
    environment:
      POSTGRES_USER: gorules
      POSTGRES_PASSWORD: your-secure-password
      POSTGRES_DB: gorules
    volumes:
      - postgres_data:/var/lib/postgresql/data
    ports:
      - '5432:5432'

volumes:
  postgres_data:
```

Start the services:

```bash theme={null}
docker-compose up -d
```

Access BRMS at [http://localhost:9080](http://localhost:9080).

## Scaling

For multiple BRMS instances:

```yaml theme={null}
services:
  brms:
    image: gorules/brms
    deploy:
      replicas: 3
    # ... rest of config
```

Use with a load balancer or Docker Swarm for production scaling.

## Backup

Backup the PostgreSQL volume:

```bash theme={null}
# Stop services
docker-compose stop

# Backup volume
docker run --rm \
  -v gorules_postgres_data:/data \
  -v $(pwd):/backup \
  alpine tar czf /backup/postgres-backup.tar.gz -C /data .

# Restart services
docker-compose start
```

## Upgrade

Update to the latest version:

```bash theme={null}
# Pull latest image
docker-compose pull

# Recreate with new image
docker-compose up -d
```

The BRMS automatically runs database migrations on startup.

## Troubleshooting

### Container won't start

Check logs:

```bash theme={null}
docker-compose logs brms
```

Common issues:

* Invalid `LICENSE_KEY`
* Database connection failed
* Missing required environment variables

### Database connection errors

Verify PostgreSQL is healthy:

```bash theme={null}
docker-compose exec postgres pg_isready -U gorules
```

### Reset everything

Remove all data and start fresh:

```bash theme={null}
docker-compose down -v
docker-compose up -d
```

<Warning>
  This deletes all data including the PostgreSQL volume.
</Warning>
