services:

  caddy-proxy:
    image: docker.io/openvidu/openvidu-caddy-local:main
    restart: unless-stopped
    extra_hosts:
      - host.docker.internal:host-gateway
    environment:
      - LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-}
      - LIVEKIT_API_KEY=${LIVEKIT_API_KEY:-devkey}
      - LIVEKIT_API_SECRET=${LIVEKIT_API_SECRET:-secret}
      - DASHBOARD_ADMIN_USERNAME=${DASHBOARD_ADMIN_USERNAME:-admin}
      - DASHBOARD_ADMIN_PASSWORD=${DASHBOARD_ADMIN_PASSWORD:-admin}
      - MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY:-minioadmin}
      - MINIO_SECRET_KEY=${MINIO_SECRET_KEY:-minioadmin}
      - MEET_INITIAL_ADMIN_USER=${MEET_INITIAL_ADMIN_USER:-admin}
      - MEET_INITIAL_ADMIN_PASSWORD=${MEET_INITIAL_ADMIN_PASSWORD:-admin}
      - MEET_INITIAL_API_KEY=${MEET_INITIAL_API_KEY:-meet-api-key}
    volumes:
      - scripts:/scripts
      - /etc/localtime:/etc/localtime:ro
    entrypoint: /bin/sh /scripts/entrypoint_caddy.sh
    ports:
      - 5443:5443
      - 6443:6443
      - 7443:7443
      - 7880:7880
      - 9443:9443
    depends_on:
      setup:
        condition: service_completed_successfully

  redis:
    image: docker.io/redis:8.2.2-alpine
    restart: unless-stopped
    ports:
      - 6379:6379
    volumes:
      - redis:/data
      - /etc/localtime:/etc/localtime:ro
    command: >
      redis-server
      --bind 0.0.0.0
      --requirepass ${REDIS_PASSWORD:-redispassword}
    depends_on:
      setup:
        condition: service_completed_successfully

  minio:
    image: docker.io/openvidu/minio:2025.9.7-debian-12-r3
    restart: unless-stopped
    ports:
      - 9000:9000
    environment:
      - MINIO_ROOT_USER=${MINIO_ACCESS_KEY:-minioadmin}
      - MINIO_ROOT_PASSWORD=${MINIO_SECRET_KEY:-minioadmin}
      - MINIO_DEFAULT_BUCKETS=openvidu-appdata
      - MINIO_CONSOLE_SUBPATH=/minio-console
      - MINIO_BROWSER_REDIRECT_URL=http://localhost:7880/minio-console
      - MINIO_BROWSER=on
    volumes:
      - minio-data:/bitnami/minio/data
      - minio-certs:/certs
      - /etc/localtime:/etc/localtime:ro
    depends_on:
      setup:
        condition: service_completed_successfully

  mongo:
    image: docker.io/openvidu/mongodb:8.0.15-r0
    restart: unless-stopped
    ports:
      - 27017:27017
    volumes:
      - mongo-data:/bitnami/mongodb
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MONGODB_ROOT_USER=${MONGO_ADMIN_USERNAME:-mongoadmin}
      - MONGODB_ROOT_PASSWORD=${MONGO_ADMIN_PASSWORD:-mongoadmin}
      - MONGODB_ADVERTISED_HOSTNAME=mongo
      - MONGODB_REPLICA_SET_MODE=primary
      - MONGODB_REPLICA_SET_NAME=rs0
      - MONGODB_REPLICA_SET_KEY=devreplicasetkey
    depends_on:
      setup:
        condition: service_completed_successfully

  dashboard:
    image: docker.io/openvidu/openvidu-dashboard:main
    restart: unless-stopped
    environment:
      - SERVER_PORT=5000
      - ADMIN_USERNAME=${DASHBOARD_ADMIN_USERNAME:-admin}
      - ADMIN_PASSWORD=${DASHBOARD_ADMIN_PASSWORD:-admin}
      - DATABASE_URL=mongodb://${MONGO_ADMIN_USERNAME:-mongoadmin}:${MONGO_ADMIN_PASSWORD:-mongoadmin}@mongo:27017/?replicaSet=rs0&readPreference=primaryPreferred
    volumes:
      - /etc/localtime:/etc/localtime:ro
    depends_on:
      setup:
        condition: service_completed_successfully

  openvidu:
    image: docker.io/openvidu/openvidu-server:main
    restart: unless-stopped
    extra_hosts:
      - host.docker.internal:host-gateway
    environment:
      - LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-}
    ports:
      - 3478:3478/udp
      - 7881:7881/tcp
      - 7900-7999:7900-7999/udp
    entrypoint: /bin/sh /scripts/entrypoint_openvidu.sh
    command: --config /config/livekit.yaml
    volumes:
      - scripts:/scripts
      - config:/config
      - /etc/localtime:/etc/localtime:ro
    depends_on:
      setup:
        condition: service_completed_successfully

  ingress:
    image: docker.io/openvidu/ingress:main
    restart: unless-stopped
    extra_hosts:
      - host.docker.internal:host-gateway
    ports:
      - 1935:1935
      - 8085:8085
      - 7895:7895/udp
    environment:
      - INGRESS_CONFIG_FILE=/config/ingress.yaml
    volumes:
      - config:/config
      - /etc/localtime:/etc/localtime:ro
    depends_on:
      setup:
        condition: service_completed_successfully

  egress:
    image: docker.io/openvidu/egress:main
    restart: unless-stopped
    extra_hosts:
      - host.docker.internal:host-gateway
    environment:
      - EGRESS_CONFIG_FILE=/config/egress.yaml
    volumes:
      - config:/config
      - egress-data:/home/egress/tmp
      - /etc/localtime:/etc/localtime:ro
    depends_on:
      setup:
        condition: service_completed_successfully

  operator:
    image: docker.io/openvidu/openvidu-operator:main
    restart: unless-stopped
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - agents-config:/agents-config
      - operator-deployment:/deployment
      - /etc/localtime:/etc/localtime:ro
    environment:
      - MODE=agent-manager-local
      - DEPLOYMENT_FILES_DIR=/deployment
      - AGENTS_CONFIG_DIR=/agents-config
      - NETWORK_NAME=openvidu-community
      - AGENTS_CONFIG_VOLUME=openvidu-agents-config
      - LIVEKIT_URL=ws://openvidu:7880/
      - LIVEKIT_API_KEY=${LIVEKIT_API_KEY:-devkey}
      - LIVEKIT_API_SECRET=${LIVEKIT_API_SECRET:-secret}
      - REDIS_ADDRESS=redis:6379
      - REDIS_PASSWORD=${REDIS_PASSWORD:-redispassword}
    depends_on:
      setup:
        condition: service_completed_successfully

  openvidu-meet:
    image: docker.io/openvidu/openvidu-meet:main
    restart: on-failure
    ports:
      - 9080:6080
    extra_hosts:
      - host.docker.internal:host-gateway
    environment:
      - LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-}
      - SERVER_PORT=6080
      - MEET_LOG_LEVEL=info
      - MEET_NAME_ID=openviduMeet-LOCAL
      - MEET_INITIAL_API_KEY=${MEET_INITIAL_API_KEY:-meet-api-key}
      - MEET_INITIAL_ADMIN_USER=${MEET_INITIAL_ADMIN_USER:-admin}
      - MEET_INITIAL_ADMIN_PASSWORD=${MEET_INITIAL_ADMIN_PASSWORD:-admin}
      - MEET_COOKIE_SECURE=false
      - MEET_INITIAL_WEBHOOK_ENABLED=true
      - MEET_INITIAL_WEBHOOK_URL=http://host.docker.internal:6080/webhook
      - LIVEKIT_URL_PRIVATE=ws://openvidu:7880/
      - LIVEKIT_API_KEY=${LIVEKIT_API_KEY:-devkey}
      - LIVEKIT_API_SECRET=${LIVEKIT_API_SECRET:-secret}
      - MEET_S3_BUCKET=openvidu-appdata
      - MEET_S3_SUBBUCKET=openvidu-meet
      - MEET_S3_SERVICE_ENDPOINT=http://minio:9000
      - MEET_S3_ACCESS_KEY=${MINIO_ACCESS_KEY:-minioadmin}
      - MEET_S3_SECRET_KEY=${MINIO_SECRET_KEY:-minioadmin}
      - MEET_AWS_REGION=us-east-1
      - MEET_S3_WITH_PATH_STYLE_ACCESS=true
      - MEET_REDIS_HOST=redis
      - MEET_REDIS_PORT=6379
      - MEET_REDIS_PASSWORD=${REDIS_PASSWORD:-redispassword}
      - MEET_REDIS_DB=0
      - MEET_MONGO_URI=mongodb://${MONGO_ADMIN_USERNAME:-mongoadmin}:${MONGO_ADMIN_PASSWORD:-mongoadmin}@mongo:27017/?replicaSet=rs0&readPreference=primaryPreferred
    volumes:
      - scripts:/scripts
      - /etc/localtime:/etc/localtime:ro
    entrypoint: /bin/sh /scripts/entrypoint_openvidu_meet.sh
    depends_on:
      setup:
        condition: service_completed_successfully

  openvidu-meet-init:
    image: docker.io/openvidu/openvidu-operator:main
    restart: on-failure
    environment:
      - MODE=local-ready-check
      - OPENVIDU_ENVIRONMENT=local-meet
      - LAN_PRIVATE_IP=${LAN_PRIVATE_IP:-}
      - DASHBOARD_ADMIN_USERNAME=${DASHBOARD_ADMIN_USERNAME:-admin}
      - DASHBOARD_ADMIN_PASSWORD=${DASHBOARD_ADMIN_PASSWORD:-admin}
      - MINIO_ACCESS_KEY=${MINIO_ACCESS_KEY:-minioadmin}
      - MINIO_SECRET_KEY=${MINIO_SECRET_KEY:-minioadmin}
      - LIVEKIT_API_KEY=${LIVEKIT_API_KEY:-devkey}
      - LIVEKIT_API_SECRET=${LIVEKIT_API_SECRET:-secret}
      - MEET_INITIAL_ADMIN_USER=${MEET_INITIAL_ADMIN_USER:-admin}
      - MEET_INITIAL_ADMIN_PASSWORD=${MEET_INITIAL_ADMIN_PASSWORD:-admin}
      - MEET_INITIAL_API_KEY=${MEET_INITIAL_API_KEY:-meet-api-key}
    volumes:
      - scripts:/scripts
      - /etc/localtime:/etc/localtime:ro
    entrypoint: /bin/sh /scripts/entrypoint_ready_check.sh
    depends_on:
      - caddy-proxy
      - redis
      - minio
      - mongo
      - dashboard
      - openvidu
      - ingress
      - egress
      - operator
      - openvidu-meet

volumes:
  scripts:
    name: openvidu-scripts
  config:
    name: openvidu-config
  agents-config:
    name: openvidu-agents-config
  minio-certs:
    name: openvidu-minio-certs
  mongodb-config:
    name: openvidu-mongodb-config
  redis:
    name: openvidu-redis
  minio-data:
    name: openvidu-minio-data
  mongo-data:
    name: openvidu-mongo-data
  egress-data:
    name: openvidu-egress-data
  operator-deployment:
    name: openvidu-operator-deployment
