version: '3.3'
services:
  web:
    image: ghcr.io/theindexmoe/index
    container_name: index-web
    restart: unless-stopped
    ports:
      - '3000:3000'
    environment:
      NEXT_PUBLIC_SITE_NAME: ${NEXT_PUBLIC_SITE_NAME}

      # domain url for sessions
      NEXTAUTH_URL: ${NEXTAUTH_URL}
      NEXT_PUBLIC_DOMAIN: ${NEXT_PUBLIC_DOMAIN}
      NEXTAUTH_SECRET: ${NEXTAUTH_SECRET}

      # provide your own url to your own db setup
      DATABASE_URL: ${DATABASE_URL}

      # provide your own url to your own redis setup
      CACHE_URL: ${CACHE_URL}

      # pass your own running chrome instance
      CHROME_URL: ${CHROME_URL}

      AUDIT_WEBHOOK: ${AUDIT_WEBHOOK}
      
      # SOCKS5 Proxy for pinging
      SOCKS_PROXY: ${SOCKS_PROXY}

      # OAuth2
      DISCORD_CLIENT_ID: ${DISCORD_CLIENT_ID}
      DISCORD_CLIENT_SECRET: ${DISCORD_CLIENT_SECRET}
      DISCORD_BOT_TOKEN: ${DISCORD_BOT_TOKEN}

      # Setup login whitelist
      SETUP_WHITELIST_DISCORD_ID: ${SETUP_WHITELIST_DISCORD_ID}
    depends_on:
      - mongo
      - redis
      - chrome

  mongo:
    image: mongo
    container_name: index-db
    restart: unless-stopped
    volumes:
      - ./db:/data/db

  redis:
    image: redis
    container_name: index-cache
    restart: unless-stopped

  chrome:
    image: browserless/chrome
    container_name: index-chrome
    restart: unless-stopped

  # this will not run if not explicitly called via docker-compose --profile dev
  mongo-express:
    image: mongo-express
    container_name: mongo-express
    profiles:
      - 'dev'
    environment:
      ME_CONFIG_BASICAUTH_USERNAME: ${ME_CONFIG_BASICAUTH_USERNAME}
      ME_CONFIG_BASICAUTH_PASSWORD: ${ME_CONFIG_BASICAUTH_PASSWORD}
      ME_CONFIG_SITE_GRIDFS_ENABLED: 'true'
    ports:
      - '8081:8081'
    depends_on:
      - mongo
