version: '3.8'

services:
  web:
    build: .
    ports:
      - "${FLASK_PORT:-8888}:8888"
    env_file: .env
    environment:
      - FLASK_ENV=production
      - FLASK_DEBUG=0
      - SCHEDULER_ENABLED=1
      - AUTO_SIGNAL_SCAN=1
    volumes:
      - model_cache:/app/model_cache
    depends_on:
      db:
        condition: service_healthy
    restart: unless-stopped

  db:
    image: mysql:8.0
    environment:
      MYSQL_ROOT_PASSWORD: ${DB_ROOT_PASSWORD:-rootpassword}
      MYSQL_DATABASE: ${DB_NAME:-investasikamu}
      MYSQL_USER: ${DB_USER:-investasikamu}
      MYSQL_PASSWORD: ${DB_PASSWORD}
    ports:
      - "${DB_PORT:-3306}:3306"
    volumes:
      - mysql_data:/var/lib/mysql
    healthcheck:
      test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
      interval: 10s
      timeout: 5s
      retries: 5
    restart: unless-stopped

volumes:
  mysql_data:
  model_cache:
