119 lines
4.2 KiB
YAML
119 lines
4.2 KiB
YAML
version: '3.4'
|
|
|
|
# This is an example docker-compose file to quickly test an IPFS Cluster
|
|
# with multiple peers on a contained environment.
|
|
|
|
# It runs 3 cluster peers (cluster0, cluster1...) attached to go-ipfs daemons
|
|
# (ipfs0, ipfs1...) using the CRDT consensus component. Cluster peers
|
|
# autodiscover themselves using mDNS on the docker internal network.
|
|
#
|
|
# To interact with the cluster use "ipfs-cluster-ctl" (the cluster0 API port is
|
|
# exposed to the locahost. You can also "docker exec -ti cluster0 sh" and run
|
|
# it from the container. "ipfs-cluster-ctl peers ls" should show all 3 peers a few
|
|
# seconds after start.
|
|
#
|
|
# For persistence, a "compose" folder is created and used to store configurations
|
|
# and states. This can be used to edit configurations in subsequent runs. It looks
|
|
# as follows:
|
|
#
|
|
# 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:latest
|
|
# ports:
|
|
# - "4001:4001" # ipfs swarm - expose if needed/wanted
|
|
# - "5001:5001" # ipfs api - expose if needed/wanted
|
|
# - "8080:8080" # ipfs gateway - expose if needed/wanted
|
|
volumes:
|
|
- ./compose/ipfs0:/data/ipfs
|
|
|
|
cluster0:
|
|
container_name: cluster0
|
|
image: ipfs/ipfs-cluster:latest
|
|
depends_on:
|
|
- ipfs0
|
|
environment:
|
|
CLUSTER_PEERNAME: cluster0
|
|
CLUSTER_SECRET: ${CLUSTER_SECRET} # From shell variable if set
|
|
CLUSTER_IPFSHTTP_NODEMULTIADDRESS: /dns4/ipfs0/tcp/5001
|
|
CLUSTER_CRDT_TRUSTEDPEERS: '*' # Trust all peers in Cluster
|
|
CLUSTER_RESTAPI_HTTPLISTENMULTIADDRESS: /ip4/0.0.0.0/tcp/9094 # Expose API
|
|
CLUSTER_MONITORPINGINTERVAL: 2s # Speed up peer discovery
|
|
ports:
|
|
# Open API port (allows ipfs-cluster-ctl usage on host)
|
|
- "127.0.0.1:9094:9094"
|
|
# The cluster swarm port would need to be exposed if this container
|
|
# was to connect to cluster peers on other hosts.
|
|
# But this is just a testing cluster.
|
|
# - "9095:9095" # Cluster IPFS Proxy endpoint
|
|
# - "9096:9096" # Cluster swarm endpoint
|
|
volumes:
|
|
- ./compose/cluster0:/data/ipfs-cluster
|
|
|
|
##################################################################################
|
|
## Cluster PEER 1 ################################################################
|
|
##################################################################################
|
|
|
|
# See Cluster PEER 0 for comments (all removed here and below)
|
|
ipfs1:
|
|
container_name: ipfs1
|
|
image: ipfs/go-ipfs:latest
|
|
volumes:
|
|
- ./compose/ipfs1:/data/ipfs
|
|
|
|
cluster1:
|
|
container_name: cluster1
|
|
image: ipfs/ipfs-cluster:latest
|
|
depends_on:
|
|
- ipfs1
|
|
environment:
|
|
CLUSTER_PEERNAME: cluster1
|
|
CLUSTER_SECRET: ${CLUSTER_SECRET}
|
|
CLUSTER_IPFSHTTP_NODEMULTIADDRESS: /dns4/ipfs1/tcp/5001
|
|
CLUSTER_CRDT_TRUSTEDPEERS: '*'
|
|
CLUSTER_MONITORPINGINTERVAL: 2s # Speed up peer discovery
|
|
volumes:
|
|
- ./compose/cluster1:/data/ipfs-cluster
|
|
|
|
##################################################################################
|
|
## Cluster PEER 2 ################################################################
|
|
##################################################################################
|
|
|
|
# See Cluster PEER 0 for comments (all removed here and below)
|
|
ipfs2:
|
|
container_name: ipfs2
|
|
image: ipfs/go-ipfs:latest
|
|
volumes:
|
|
- ./compose/ipfs2:/data/ipfs
|
|
|
|
cluster2:
|
|
container_name: cluster2
|
|
image: ipfs/ipfs-cluster:latest
|
|
depends_on:
|
|
- ipfs2
|
|
environment:
|
|
CLUSTER_PEERNAME: cluster2
|
|
CLUSTER_SECRET: ${CLUSTER_SECRET}
|
|
CLUSTER_IPFSHTTP_NODEMULTIADDRESS: /dns4/ipfs2/tcp/5001
|
|
CLUSTER_CRDT_TRUSTEDPEERS: '*'
|
|
CLUSTER_MONITORPINGINTERVAL: 2s # Speed up peer discovery
|
|
volumes:
|
|
- ./compose/cluster2:/data/ipfs-cluster
|
|
|
|
# For adding more peers, copy PEER 1 and rename things to ipfs2, cluster2.
|
|
# Keep bootstrapping to cluster0.
|