version: '3.8'

# ─── DEV/LOCAL ONLY ─────────────────────────────────────────────
# For production (cPanel), deploy without Docker — see DEPLOY_CPANEL.md
# Usage: docker compose up -d

services:
  db:
    image: mysql:8.0
    container_name: thinkers_db
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: rootpassword
      MYSQL_DATABASE: thinkers_db
      MYSQL_USER: thinkers
      MYSQL_PASSWORD: thinkers_pass
    ports:
      - "3307:3306"
    volumes:
      - mysql_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-u", "root", "-prootpassword"]
      interval: 10s
      timeout: 5s
      retries: 5

  api:
    build:
      context: .
      dockerfile: Dockerfile.dev
    container_name: thinkers_api
    restart: unless-stopped
    depends_on:
      db:
        condition: service_healthy
    ports:
      - "4000:4000"
    environment:
      NODE_ENV: development
      PORT: 4000
      DATABASE_URL: mysql://thinkers:thinkers_pass@db:3306/thinkers_db
      JWT_ACCESS_SECRET: dev_access_secret_at_least_32_chars!!
      JWT_REFRESH_SECRET: dev_refresh_secret_at_least_32_chars!
      JWT_ACCESS_EXPIRES: 15m
      JWT_REFRESH_EXPIRES: 7d
      CORS_ORIGINS: http://localhost:3000,http://localhost:3001
      UPLOAD_DIR: /app/uploads
      UPLOADS_PUBLIC_URL: http://localhost:4000/uploads
      COOKIE_SECURE: "false"
      COOKIE_SAME_SITE: lax
      ADMIN_EMAIL: admin@thinkers-production.com
      ADMIN_PASSWORD: ChangeMe!Dev123
    volumes:
      - ./src:/app/src:ro
      - ./prisma:/app/prisma:ro
      - uploads_data:/app/uploads

volumes:
  mysql_data:
  uploads_data:
