name: sequin

services:
  sequin:
    image: sequin/sequin:latest
    pull_policy: always
    ports:
      - "7376:7376"
    environment:
      - PG_HOSTNAME=sequin_postgres
      - PG_DATABASE=sequin
      - PG_PORT=5432
      - PG_USERNAME=postgres
      - PG_PASSWORD=postgres
      - PG_POOL_SIZE=20
      # Un-comment for SSL
      # - PG_SSL=true
      - SECRET_KEY_BASE=wDPLYus0pvD6qJhKJICO4dauYPXfO/Yl782Zjtpew5qRBDp7CZvbWtQmY0eB13If
      - VAULT_KEY=2Sig69bIpuSm2kv0VQfDekET2qy8qUZGI8v3/h3ASiY=
      - REDIS_URL=redis://sequin_redis:6379
      - CONFIG_FILE_PATH=/config/playground.yml
    volumes:
      - ./playground.yml:/config/playground.yml
    depends_on:
      sequin_redis:
        condition: service_started
      sequin_postgres:
        condition: service_healthy

  sequin_postgres:
    image: postgres:16
    ports:
      - "7377:5432"
    environment:
      - POSTGRES_DB=sequin
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgres
    command: ["postgres", "-c", "wal_level=logical"]
    volumes:
      - sequin_postgres_data:/var/lib/postgresql/data
      # Creates a sample database for Sequin's Quickstart guide
      - ./postgres-init:/docker-entrypoint-initdb.d
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres -d sequin"]
      interval: 10s
      timeout: 2s
      retries: 5
      start_period: 2s
      start_interval: 1s

  sequin_redis:
    image: redis:7
    ports:
      - "7378:6379"
    command: ["redis-server", "--port", "6379"]
    volumes:
      - sequin_redis_data:/data

  sequin_prometheus:
    image: prom/prometheus
    volumes:
      - ./prometheus.yml:/etc/prometheus/prometheus.yml
    ports:
      - "9090:9090"

  sequin_grafana:
    image: grafana/grafana
    ports:
      - "3000:3000"
    depends_on:
      - sequin_prometheus
    volumes:
      - sequin_grafana_data:/var/lib/grafana
      - ./grafana_datasource.yml:/etc/grafana/provisioning/datasources/datasource.yml
      - ./grafana_dashboard.yml:/etc/grafana/provisioning/dashboards/dashboard.yml
      - ./dashboard.json:/etc/grafana/dashboards/dashboards/sequin.json

volumes:
  sequin_postgres_data:
  sequin_redis_data:
  sequin_grafana_data:

# Un-comment this to enable IPv6
# You may need to run
# `docker compose down --volumes --remove-orphans`
# to remove the existing network and start fresh
#
# networks:
#   default:
#     enable_ipv6: true
#     ipam:
#       config:
#         - subnet: "2001:db8:1::/64"