# This file can be used to setup a Dgraph cluster with 3 Dgraph Alphas and 1 Dgraph Zero node on a # Docker Swarm with replication. # It expects three virtual machines with hostnames aws01, aws02, and aws03 to be part of the swarm. # There is a constraint to make sure that each Dgraph Alpha runs on a particular host. # Data would be persisted to a Docker volume called data-volume on the virtual machines which are # part of the swarm. # Run `docker stack deploy -c docker-compose-multi.yml` on the Swarm leader to start the cluster. # NOTE: whitelisting is set to private address ranges, this is ONLY for a local setup # please change it accordingly for your production setup # more here https://dgraph.io/docs/deploy/dgraph-administration/#whitelisting-admin-operations version: "3.2" networks: dgraph: services: zero: image: dgraph/dgraph:latest volumes: - data-volume:/dgraph ports: - 5080:5080 - 6080:6080 networks: - dgraph deploy: placement: constraints: - node.hostname == aws01 command: dgraph zero --my=zero:5080 --replicas 3 alpha1: image: dgraph/dgraph:latest hostname: "alpha1" volumes: - data-volume:/dgraph ports: - 8080:8080 - 9080:9080 networks: - dgraph deploy: placement: constraints: - node.hostname == aws01 command: dgraph alpha --my=alpha1:7080 --security whitelist=10.0.0.0/8,172.0.0.0/8,192.168.0.0/16,127.0.0.1 --zero=zero:5080 alpha2: image: dgraph/dgraph:latest hostname: "alpha2" volumes: - data-volume:/dgraph ports: - 8081:8081 - 9081:9081 networks: - dgraph deploy: replicas: 1 placement: constraints: - node.hostname == aws02 command: dgraph alpha --my=alpha2:7081 --security whitelist=10.0.0.0/8,172.0.0.0/8,192.168.0.0/16,127.0.0.1 --zero=zero:5080 -o 1 alpha3: image: dgraph/dgraph:latest hostname: "alpha3" volumes: - data-volume:/dgraph ports: - 8082:8082 - 9082:9082 networks: - dgraph deploy: replicas: 1 placement: constraints: - node.hostname == aws03 command: dgraph alpha --my=alpha3:7082 --security whitelist=10.0.0.0/8,172.0.0.0/8,192.168.0.0/16,127.0.0.1 --zero=zero:5080 -o 2 volumes: data-volume: