version: '3.8'

services:
  # MongoDB Database
  mongodb:
    image: mongo:7
    container_name: wiki-mongodb
    restart: unless-stopped
    ports:
      - "27017:27017"
    environment:
      MONGO_INITDB_ROOT_USERNAME: admin
      MONGO_INITDB_ROOT_PASSWORD: changeme
      MONGO_INITDB_DATABASE: wiki-ghostguild
    volumes:
      - mongodb_data:/data/db
      - ./docker/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
    networks:
      - wiki-network

  # Wiki Application (for local development)
  # Uncomment to run the app in Docker
  # wiki:
  #   build: .
  #   container_name: wiki-app
  #   restart: unless-stopped
  #   ports:
  #     - "3000:3000"
  #   environment:
  #     MONGODB_URI: mongodb://admin:changeme@mongodb:27017/wiki-ghostguild?authSource=admin
  #     NODE_ENV: development
  #   depends_on:
  #     - mongodb
  #   networks:
  #     - wiki-network
  #   volumes:
  #     - ./app:/app/app
  #     - ./server:/app/server
  #     - ./content:/app/content

  # Optional: Mongo Express for database management
  mongo-express:
    image: mongo-express:latest
    container_name: wiki-mongo-express
    restart: unless-stopped
    ports:
      - "8081:8081"
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME: admin
      ME_CONFIG_MONGODB_ADMINPASSWORD: changeme
      ME_CONFIG_MONGODB_URL: mongodb://admin:changeme@mongodb:27017/
      ME_CONFIG_BASICAUTH: false
    depends_on:
      - mongodb
    networks:
      - wiki-network

volumes:
  mongodb_data:
    driver: local

networks:
  wiki-network:
    driver: bridge