version: '3.8'

services:
  # MongoDB Database
  mongodb:
    image: mongo:7.0
    container_name: abbasfit_mongodb
    restart: unless-stopped
    ports:
      - "27017:27017"
    volumes:
      - mongodb_data:/data/db
    environment:
      - MONGO_INITDB_DATABASE=abbasfit_db
    networks:
      - abbasfit_network

  # FastAPI Backend
  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: abbasfit_backend
    restart: unless-stopped
    ports:
      - "8001:8001"
    depends_on:
      - mongodb
    environment:
      - MONGO_URL=mongodb://mongodb:27017
      - DB_NAME=abbasfit_db
      - JWT_SECRET_KEY=${JWT_SECRET_KEY:-your-secret-key-change-in-production}
      - EMERGENT_LLM_KEY=${EMERGENT_LLM_KEY:-}
      - ALLOWED_ORIGINS=${ALLOWED_ORIGINS:-*}
    networks:
      - abbasfit_network

  # Web Frontend (Optional - run after building with 'npx expo export --platform web')
  web:
    image: nginx:alpine
    container_name: abbasfit_web
    restart: unless-stopped
    ports:
      - "80:80"
    volumes:
      - ./frontend/dist:/usr/share/nginx/html:ro
      - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
    depends_on:
      - backend
    networks:
      - abbasfit_network

volumes:
  mongodb_data:
    driver: local

networks:
  abbasfit_network:
    driver: bridge
