version: '3.8'

services:
  # Node.js API
  api:
    build:
      context: .
      dockerfile: Dockerfile
    container_name: monkapi-node
    restart: unless-stopped
    ports:
      - "3000:3000"
    environment:
      - NODE_ENV=development
      - DATABASE_URL=mysql://monkapi:monkapi_password@mysql:3306/monkapi
      - REDIS_HOST=redis
      - REDIS_PORT=6379
    depends_on:
      - mysql
      - redis
    volumes:
      - .:/app
      - /app/node_modules
    networks:
      - monkapi-network

  # MySQL Database
  mysql:
    image: mysql:8.0
    container_name: monkapi-mysql
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: root_password
      MYSQL_DATABASE: monkapi
      MYSQL_USER: monkapi
      MYSQL_PASSWORD: monkapi_password
    ports:
      - "3306:3306"
    volumes:
      - mysql_data:/var/lib/mysql
    networks:
      - monkapi-network

  # Redis (Cache, Queue, Sessions)
  redis:
    image: redis:7-alpine
    container_name: monkapi-redis
    restart: unless-stopped
    ports:
      - "6379:6379"
    volumes:
      - redis_data:/data
    networks:
      - monkapi-network

  # Redis Commander (GUI for Redis)
  redis-commander:
    image: rediscommander/redis-commander:latest
    container_name: monkapi-redis-commander
    restart: unless-stopped
    environment:
      - REDIS_HOSTS=local:redis:6379
    ports:
      - "8081:8081"
    depends_on:
      - redis
    networks:
      - monkapi-network

volumes:
  mysql_data:
  redis_data:

networks:
  monkapi-network:
    driver: bridge
