# Shared development infra for AstroAyodhya monorepo.
# Brings up: MySQL 8, Redis 7, Meilisearch, MinIO (S3-compatible), Mailpit.
# Services use the env values from .env at workspace root.

services:
  mysql:
    image: mysql:8.0
    container_name: aa-mysql
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-rootsecret}
      MYSQL_DATABASE: ${DB_DATABASE:-astroayodhya}
      MYSQL_USER: ${DB_USERNAME:-aa_user}
      MYSQL_PASSWORD: ${DB_PASSWORD:-aa_password}
    ports:
      - "${DB_PORT:-3306}:3306"
    volumes:
      - mysql-data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-p${DB_ROOT_PASSWORD:-rootsecret}"]
      interval: 10s
      timeout: 5s
      retries: 5

  redis:
    image: redis:7-alpine
    container_name: aa-redis
    restart: unless-stopped
    ports:
      - "${REDIS_PORT:-6379}:6379"
    volumes:
      - redis-data:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 5s
      retries: 5

  meilisearch:
    image: getmeili/meilisearch:v1.6
    container_name: aa-meilisearch
    restart: unless-stopped
    environment:
      MEILI_MASTER_KEY: ${MEILI_MASTER_KEY:-aa_meili_master_key_dev}
      MEILI_ENV: development
    ports:
      - "${MEILI_PORT:-7700}:7700"
    volumes:
      - meili-data:/meili_data

  minio:
    # S3-compatible object store for local dev (mirrors S3 buckets aa-pdfs, aa-media)
    image: minio/minio:latest
    container_name: aa-minio
    restart: unless-stopped
    command: server /data --console-address ":9001"
    environment:
      MINIO_ROOT_USER: ${MINIO_ROOT_USER:-minioadmin}
      MINIO_ROOT_PASSWORD: ${MINIO_ROOT_PASSWORD:-minioadmin}
    ports:
      - "${MINIO_PORT:-9000}:9000"
      - "${MINIO_CONSOLE_PORT:-9001}:9001"
    volumes:
      - minio-data:/data

  mailpit:
    image: axllent/mailpit:latest
    container_name: aa-mailpit
    restart: unless-stopped
    ports:
      - "${MAILPIT_SMTP_PORT:-1025}:1025"
      - "${MAILPIT_UI_PORT:-8025}:8025"

volumes:
  mysql-data:
  redis-data:
  meili-data:
  minio-data:
