github.com/unigraph-dev/dgraph@v1.1.1-0.20200923154953-8b52b426f765/contrib/config/docker/docker-compose-ha.yml (about)

     1  # This file can be used to setup a Dgraph cluster with 6 Dgraph Alphas and 3 Dgraph Zero nodes on a
     2  # Docker Swarm with replication. This setup ensures high availability for both Zero and Alpha.
     3  
     4  # It expects six virtual machines with hostnames host1, host2, host3, host4, host5 and host6 to
     5  # be part of the swarm.  There is a constraint to make sure that each Dgraph Alpha runs on a
     6  # particular host. Dgraph Zero nodes run on host1, host2 and host3.
     7  
     8  # Data would be persisted to a docker volume called data-volume on the virtual machines which are
     9  # part of the swarm.
    10  # Run `docker stack deploy -c docker-compose-ha.yml` on the Swarm leader to start the cluster.
    11  
    12  version: "3.2"
    13  networks:
    14    dgraph:
    15  services:
    16    zero_1:
    17      image: dgraph/dgraph:latest
    18      volumes:
    19        - data-volume:/dgraph
    20      ports:
    21        - 5080:5080
    22        - 6080:6080
    23      networks:
    24        - dgraph
    25      deploy:
    26        placement:
    27          constraints:
    28            - node.hostname == aws01
    29      command: dgraph zero --my=zero_1:5080 --replicas 3 --idx 1
    30    zero_2:
    31      image: dgraph/dgraph:latest
    32      volumes:
    33        - data-volume:/dgraph
    34      ports:
    35        - 5081:5081
    36        - 6081:6081
    37      networks:
    38        - dgraph
    39      deploy:
    40        placement:
    41          constraints:
    42            - node.hostname == aws02
    43      command: dgraph zero -o 1 --my=zero_2:5081 --replicas 3 --peer zero_1:5080 --idx 2
    44    zero_3:
    45      image: dgraph/dgraph:latest
    46      volumes:
    47        - data-volume:/dgraph
    48      ports:
    49        - 5082:5082
    50        - 6082:6082
    51      networks:
    52        - dgraph
    53      deploy:
    54        placement:
    55          constraints:
    56            - node.hostname == aws03
    57      command: dgraph zero -o 2 --my=zero_3:5082 --replicas 3 --peer zero_1:5080 --idx 3
    58    alpha_1:
    59      image: dgraph/dgraph:latest
    60      hostname: "alpha_1"
    61      volumes:
    62        - data-volume:/dgraph
    63      ports:
    64        - 8080:8080
    65        - 9080:9080
    66      networks:
    67        - dgraph
    68      deploy:
    69        replicas: 1
    70        placement:
    71          constraints:
    72            - node.hostname == aws01
    73      command: dgraph alpha --my=alpha_1:7080 --lru_mb=2048 --zero=zero_1:5080
    74    alpha_2:
    75      image: dgraph/dgraph:latest
    76      hostname: "alpha_2"
    77      volumes:
    78        - data-volume:/dgraph
    79      ports:
    80        - 8081:8081
    81        - 9081:9081
    82      networks:
    83        - dgraph
    84      deploy:
    85        replicas: 1
    86        placement:
    87          constraints:
    88            - node.hostname == aws02
    89      command: dgraph alpha --my=alpha_2:7081 --lru_mb=2048 --zero=zero_1:5080 -o 1
    90    alpha_3:
    91      image: dgraph/dgraph:latest
    92      hostname: "alpha_3"
    93      volumes:
    94        - data-volume:/dgraph
    95      ports:
    96        - 8082:8082
    97        - 9082:9082
    98      networks:
    99        - dgraph
   100      deploy:
   101        replicas: 1
   102        placement:
   103          constraints:
   104            - node.hostname == aws03
   105      command: dgraph alpha --my=alpha_3:7082 --lru_mb=2048 --zero=zero_1:5080 -o 2
   106    alpha_4:
   107      image: dgraph/dgraph:latest
   108      hostname: "alpha_4"
   109      volumes:
   110        - data-volume:/dgraph
   111      ports:
   112        - 8083:8083
   113        - 9083:9083
   114      networks:
   115        - dgraph
   116      deploy:
   117        placement:
   118          constraints:
   119            - node.hostname == aws04
   120      command: dgraph alpha --my=alpha_4:7083 --lru_mb=2048 --zero=zero_1:5080 -o 3
   121    alpha_5:
   122      image: dgraph/dgraph:latest
   123      hostname: "alpha_5"
   124      volumes:
   125        - data-volume:/dgraph
   126      ports:
   127        - 8084:8084
   128        - 9084:9084
   129      networks:
   130        - dgraph
   131      deploy:
   132        placement:
   133          constraints:
   134            - node.hostname == aws05
   135      command: dgraph alpha --my=alpha_5:7084 --lru_mb=2048 --zero=zero_1:5080 -o 4
   136    alpha_6:
   137      image: dgraph/dgraph:latest
   138      hostname: "alpha_6"
   139      volumes:
   140        - data-volume:/dgraph
   141      ports:
   142        - 8085:8085
   143        - 9085:9085
   144      networks:
   145        - dgraph
   146      deploy:
   147        placement:
   148          constraints:
   149            - node.hostname == aws06
   150      command: dgraph alpha --my=alpha_6:7085 --lru_mb=2048 --zero=zero_1:5080 -o 5
   151    ratel:
   152      image: dgraph/dgraph:latest
   153      hostname: "ratel"
   154      ports:
   155        - 8000:8000
   156      networks:
   157        - dgraph
   158      command: dgraph-ratel
   159  volumes:
   160    data-volume: