version: "3.7"
networks: 
  openim: 
    external: true
 
services:
  mysql:
    networks: 
      - openim
    image: mysql:5.7
    # ports:
    #   #- 13306:3306
    #   - 23306:33060
    container_name: openim_mysql
    volumes:
      - ./components/mysql/data:/var/lib/mysql
      - /etc/localtime:/etc/localtime
    environment:
      MYSQL_ROOT_PASSWORD: openIM
    restart: always

  mongodb:
    networks: 
      - openim
    image: mongo:4.4.5-bionic
    # ports:
    #   - 37017:27017
    container_name: openim_mongo
    volumes:
      - ./components/mongodb/data/db:/data/db
      - ./components/mongodb/data/logs:/data/logs
      - ./components/mongodb/data/conf:/etc/mongo
   environment:
    TZ: Asia/Shanghai
   #   - MONGO_INITDB_ROOT_USERNAME=openIM
    #  - MONGO_INITDB_ROOT_PASSWORD=openIM
    restart: always

  redis:
    networks: 
      - openim
    image: redis:6.2.4-alpine
    # ports:
    #   - 16379:6379
    container_name: openim_redis
    volumes:
      - ./components/redis/data:/data
      #redis config file
      #- ./components/redis/config/redis.conf:/usr/local/redis/config/redis.conf
    environment:
      TZ: Asia/Shanghai
    restart: always
    sysctls:
      net.core.somaxconn: 1024
    command: redis-server --requirepass openIM --appendonly yes


  zookeeper:
    networks: 
      - openim
    image: wurstmeister/zookeeper
    # ports:
    #   - 2181:2181
    container_name: openim_zookeeper
    volumes:
      - /etc/localtime:/etc/localtime
    environment:
      TZ: Asia/Shanghai
    restart: always

  kafka:
    networks: 
      - openim
    image: wurstmeister/kafka
    container_name: openim_kafka
    restart: always
    environment:
      TZ: Asia/Shanghai
      KAFKA_BROKER_ID: 0
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092
      KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092
    depends_on:
      - zookeeper

  etcd:
    networks: 
      - openim
    image: quay.io/coreos/etcd
    # ports:
    #   - 2379:2379
    #   - 2380:2380
    container_name: openim_etcd
    volumes:
      - /etc/timezone:/etc/timezone
      - /etc/localtime:/etc/localtime
    environment:
      ETCDCTL_API: 3
    restart: always
    command: /usr/local/bin/etcd --name etcd0 --data-dir /etcd-data --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls http://0.0.0.0:2379 --listen-peer-urls http://0.0.0.0:2380 --initial-advertise-peer-urls http://0.0.0.0:2380 --initial-cluster etcd0=http://0.0.0.0:2380 --initial-cluster-token tkn --initial-cluster-state new

