version: '3.8'

services:
  # MySQL Database
  mysql:
    image: mysql:8.0
    container_name: nandailseba_mysql
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-rootpassword}
      MYSQL_DATABASE: ${DB_NAME:-nandailseba_db}
      MYSQL_USER: ${DB_USER:-nandailseba_user}
      MYSQL_PASSWORD: ${DB_PASSWORD:-password}
    ports:
      - "${DB_PORT:-3306}:3306"
    volumes:
      - mysql_data:/var/lib/mysql
      - ./migrations:/docker-entrypoint-initdb.d
    networks:
      - nandailseba_network

  # Node.js API Server
  api:
    build: .
    container_name: nandailseba_api
    restart: unless-stopped
    ports:
      - "${PORT:-3000}:3000"
    environment:
      NODE_ENV: production
      PORT: 3000
      DB_HOST: mysql
      DB_PORT: 3306
      DB_USER: ${DB_USER:-nandailseba_user}
      DB_PASSWORD: ${DB_PASSWORD:-password}
      DB_NAME: ${DB_NAME:-nandailseba_db}
    volumes:
      - ./storage:/app/storage
      - ./firebase-credentials.json:/app/firebase-credentials.json:ro
    depends_on:
      - mysql
    networks:
      - nandailseba_network

volumes:
  mysql_data:

networks:
  nandailseba_network:
    driver: bridge
