version: '3.8'

services:
  db:
    image: mysql:8.0
    container_name: amanenime_mysql
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_PASSWORD:-password}
      MYSQL_DATABASE: amanenime_topup
    ports:
      - "3306:3306"
    volumes:
      - mysql_data:/var/lib/mysql
    restart: unless-stopped
    command: --default-authentication-plugin=mysql_native_password

  app:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: amanenime_app
    ports:
      - "3000:3000"
    environment:
      - DATABASE_URL=mysql://root:${DB_PASSWORD:-password}@db:3306/amanenime_topup
      - NEXTAUTH_URL=${NEXTAUTH_URL:-http://localhost:3000}
      - NEXTAUTH_SECRET=${NEXTAUTH_SECRET}
      - APP_URL=${APP_URL:-http://localhost:3000}
    depends_on:
      - db
    restart: unless-stopped
    # Jalankan migrasi prisma sebelum start (opsional, better manual di host production)

volumes:
  mysql_data:
