# OpenWA - Docker Compose for Development
# Quick Start: docker compose -f docker-compose.dev.yml up -d

services:
  # API Backend
  openwa:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: openwa-api
    ports:
      - '127.0.0.1:2785:2785'
    environment:
      - NODE_ENV=development
      - PORT=2785
      - DATABASE_TYPE=sqlite
      - DATABASE_NAME=/app/data/openwa.sqlite
      - DATABASE_SYNCHRONIZE=true
      - ENGINE_TYPE=whatsapp-web.js
      - SESSION_DATA_PATH=/app/data/sessions
      - PUPPETEER_HEADLESS=true
      - PUPPETEER_ARGS=--no-sandbox,--disable-setuid-sandbox,--disable-dev-shm-usage,--disable-gpu
      - STORAGE_TYPE=local
      - STORAGE_LOCAL_PATH=/app/data/media
      - WEBHOOK_TIMEOUT=10000
      - WEBHOOK_MAX_RETRIES=3
      - QUEUE_ENABLED=false
    volumes:
      - ./data:/app/data
    restart: unless-stopped
    healthcheck:
      test:
        [
          'CMD',
          'node',
          '-e',
          "require('http').get('http://localhost:2785/api/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))",
        ]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

  # Dashboard Frontend
  dashboard:
    build:
      context: ./dashboard
      dockerfile: Dockerfile
    container_name: openwa-dashboard
    ports:
      - '127.0.0.1:2886:80'
    depends_on:
      openwa:
        condition: service_healthy
    restart: unless-stopped

networks:
  default:
    name: openwa-network
