063c5f1b78
Fixes #865. This makes the necessary changes so that consensu is selected on "init" with a flag set, by default, to "crdt". This generates only a "crdt" or a "raft" section, not both. If the configuration file has a "raft" section, "raft" will be used to start the daemon. If it has a "crdt" section, "crdt" will be used. If it has none or both sections, an error will happen. This also affects "state *" commands, which will now autoselect how to work from the existing configuration.
99 lines
3.0 KiB
YAML
99 lines
3.0 KiB
YAML
version: '3.4'
|
|
|
|
# This is an example docker-compose file for IPFS Cluster
|
|
# It runs two Cluster peers (cluster0, cluster1) attached to two
|
|
# IPFS daemons (ipfs0, ipfs1).
|
|
#
|
|
# It expects a "compose" subfolder as follows where it will store configurations
|
|
# and states permanently:
|
|
#
|
|
# compose/
|
|
# |-- cluster0
|
|
# |-- cluster1
|
|
# |-- ipfs0
|
|
# |-- ipfs1
|
|
#
|
|
#
|
|
# During the first start, default configurations are created for all peers.
|
|
|
|
services:
|
|
|
|
##################################################################################
|
|
## Cluster PEER 0 ################################################################
|
|
##################################################################################
|
|
|
|
ipfs0:
|
|
container_name: ipfs0
|
|
image: ipfs/go-ipfs:release
|
|
ports:
|
|
- "4001:4001" # ipfs swarm
|
|
# - "5001:5001" # expose if needed/wanted
|
|
# - "8080:8080" # exposes if needed/wanted
|
|
volumes:
|
|
- ./compose/ipfs0:/data/ipfs
|
|
|
|
cluster0:
|
|
container_name: cluster0
|
|
image: ipfs/ipfs-cluster:latest
|
|
depends_on:
|
|
- ipfs0
|
|
environment:
|
|
CLUSTER_SECRET: ${CLUSTER_SECRET} # From shell variable
|
|
IPFS_API: /dns4/ipfs0/tcp/5001
|
|
ports:
|
|
- "127.0.0.1:9094:9094" # API
|
|
# - "9096:9096" # Cluster IPFS Proxy endpoint
|
|
volumes:
|
|
- ./compose/cluster0:/data/ipfs-cluster
|
|
|
|
##################################################################################
|
|
## Cluster PEER 1 ################################################################
|
|
##################################################################################
|
|
|
|
ipfs1:
|
|
container_name: ipfs1
|
|
image: ipfs/go-ipfs:release
|
|
ports:
|
|
- "4101:4001" # ipfs swarm
|
|
# - "5101:5001" # expose if needed/wanted
|
|
# - "8180:8080" # exposes if needed/wanted
|
|
volumes:
|
|
- ./compose/ipfs1:/data/ipfs
|
|
|
|
# cluster1 bootstraps to cluster0 if not bootstrapped before
|
|
cluster1:
|
|
container_name: cluster1
|
|
image: ipfs/ipfs-cluster:latest
|
|
depends_on:
|
|
- cluster0
|
|
- ipfs1
|
|
environment:
|
|
CLUSTER_SECRET: ${CLUSTER_SECRET} # From shell variable
|
|
IPFS_API: /dns4/ipfs1/tcp/5001
|
|
ports:
|
|
- "127.0.0.1:9194:9094" # API
|
|
# - "9196:9096" # Cluster IPFS Proxy endpoint
|
|
volumes:
|
|
- ./compose/cluster1:/data/ipfs-cluster
|
|
entrypoint:
|
|
- "/sbin/tini"
|
|
- "--"
|
|
# Translation: if state folder does not exist, find cluster0 id and bootstrap
|
|
# to it.
|
|
command: >-
|
|
sh -c '
|
|
cmd="daemon"
|
|
if [ ! -d /data/ipfs-cluster/badger ]; then
|
|
while ! ipfs-cluster-ctl --host /dns4/cluster0/tcp/9094 id; do
|
|
sleep 1
|
|
done
|
|
pid=`ipfs-cluster-ctl --host /dns4/cluster0/tcp/9094 id | grep -o -E "^(\w+)"`
|
|
sleep 10
|
|
cmd="daemon --bootstrap /dns4/cluster0/tcp/9096/ipfs/$$pid"
|
|
fi
|
|
exec /usr/local/bin/entrypoint.sh $$cmd
|
|
'
|
|
|
|
# For adding more peers, copy PEER 1 and rename things to ipfs2, cluster2.
|
|
# Keep bootstrapping to cluster0.
|