version: '3.4'

services:
  redis-node1:
    build:
      context: redis
    ports:
      - "7000:7000"
      - "17000:17000"
    restart: always
    entrypoint: [redis-server, /etc/redis/rediscluster.conf,    --port,"7000", --cluster-announce-ip,"${ip}"]
  redis-node2:
    build:
      context: redis
    ports:
      - "7001:7001"
      - "17001:17001"
    restart: always
    entrypoint: [redis-server, /etc/redis/rediscluster.conf,    --port,"7001",--cluster-announce-ip,"${ip}"]
  redis-node3:
    build:
      context: redis
    ports:
      - "7002:7002"
      - "17002:17002"
    restart: always
    entrypoint: [redis-server, /etc/redis/rediscluster.conf,    --port,"7002",--cluster-announce-ip,"${ip}"]
  redis-node4:
    build:
      context: redis
    ports:
      - "7003:7003"
      - "17003:17003"
    restart: always
    entrypoint: [redis-server, /etc/redis/rediscluster.conf,    --port,"7003",--cluster-announce-ip,"${ip}"]
    depends_on:
      - redis-node1
      - redis-node2
      - redis-node3
  redis-node5:
    build:
      context: redis
    ports:
      - "7004:7004"
      - "17004:17004"
    restart: always
    entrypoint: [redis-server, /etc/redis/rediscluster.conf,    --port,"7004",--cluster-announce-ip,"${ip}"]
    depends_on:
      - redis-node1
      - redis-node2
      - redis-node3
  redis-node6:
    build:
      context: redis
    ports:
      - "7005:7005"
      - "17005:17005"
    restart: always
    entrypoint: [redis-server, /etc/redis/rediscluster.conf,    --port,"7005",--cluster-announce-ip,"${ip}"]
    depends_on:
      - redis-node1
      - redis-node2
      - redis-node3
  redis-cluster-creator:
    image: redis:6.0.3
    entrypoint: [/bin/sh,-c,'echo "yes" | redis-cli --cluster create ${ip}:7000 ${ip}:7001 ${ip}:7002 ${ip}:7003 ${ip}:7004 ${ip}:7005 --cluster-replicas 1']
    depends_on:
      - redis-node1
      - redis-node2
      - redis-node3
      - redis-node4
      - redis-node5
      - redis-node6
