version: '3'
services:
  zookeeper:
    image: wurstmeister/zookeeper:3.4.6                    # 镜像
    container_name: zookeeper
    ports:
      - ${ZOOKEEPER_PORT}:2181                 # 对外暴露的端口号
    networks:
      - ${PROJECT_NETWORK}
    restart: always

  kafka:
    image: wurstmeister/kafka:2.12-2.4.1
    container_name: kafka
    volumes:
      - /etc/localtime:/etc/localtime
      - /var/kafka-logs:/kafka
      - /var/run/docker.sock:/var/run/docker.sock
    ports:
      - ${KAFKA_PORT}:${KAFKA_PORT}
    environment:
      KAFKA_ADVERTISED_HOST_NAME: 172.17.0.1        ## 修改:宿主机IP
      KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181       ## 卡夫卡运行是基于zookeeper的
      KAFKA_ADVERTISED_PORT: ${KAFKA_PORT}
      KAFKA_LOG_RETENTION_HOURS: 120
      KAFKA_MESSAGE_MAX_BYTES: 10000000
      KAFKA_REPLICA_FETCH_MAX_BYTES: 10000000
      KAFKA_GROUP_MAX_SESSION_TIMEOUT_MS: 60000
      KAFKA_NUM_PARTITIONS: 3
      KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:${KAFKA_PORT}
      KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://${KAFKA_HOST}:${KAFKA_PORT}
      KAFKA_DELETE_RETENTION_MS: 1000
      ALLOW_PLAINTEXT_LISTENER: 'yes'
      KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'true'
      KAFKA_DELETE_TOPIC_ENABLE: 'true'
#      KAFKA_CREATE_TOPICS: ${KAFKA_CREATE_TOPICS}
    networks:
      - ${PROJECT_NETWORK}
    depends_on:
      - zookeeper


  mongodb:
    image: mongo:5.0.9
    volumes:
      #- /var/lib/docker/volumes/mdb-data/_data:/mongodata
      - mongo-data:/data/db
    ports:
      - ${MONGO_RS0_PORT}:27017
    command: mongod --dbpath /data/db
    networks:
      - ${PROJECT_NETWORK}

  etcd:
    image: bitnami/etcd:latest
    ports:
      - ${ETCD_PORT}:2379
    networks:
      - ${PROJECT_NETWORK}
    environment:
      - ALLOW_NONE_AUTHENTICATION=yes
      - ETCD_LISTEN_CLIENT_URLS=http://0.0.0.0:2379
      - ETCD_ADVERTISE_CLIENT_URLS=http://172.17.0.1:2379

  redis:
    image: redis
    ports:
      - ${REDIS_PORT}:6376
    command: ["redis-server", "--port", "6376"]
    networks:
      - ${PROJECT_NETWORK}

volumes:
  mongo-data:

networks:
  livegameservernet:
    driver: bridge
    external: true

