-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: dynamic members docker packaging and compose setup (#130)
* add docker file for single node * create a 3-node cluster with docker compose * feat: Add static bootstrap example's docker-compose.yml * chore: Add whitespace on file end --------- Co-authored-by: Gyubong <[email protected]>
- Loading branch information
1 parent
99e0c0a
commit d02b953
Showing
6 changed files
with
133 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
.dockerignore | ||
Dockerfile | ||
.git | ||
.gitignore | ||
|
||
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM rust:latest AS builder | ||
|
||
WORKDIR /raftify | ||
|
||
COPY . . | ||
|
||
RUN apt-get update && apt-get install -y protobuf-compiler | ||
RUN cargo clean | ||
RUN cargo build --workspace |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Docker-compose example for running a 3-node cluster. | ||
services: | ||
node1: | ||
build: | ||
context: ../../../ | ||
dockerfile: ./Dockerfile | ||
image: raftify_img | ||
container_name: node1 | ||
command: ["./target/debug/memstore-dynamic-members", "--raft-addr=node1:60061", "--web-server=0.0.0.0:8001"] | ||
ports: | ||
- "8001:8001" | ||
expose: | ||
- "8001" | ||
|
||
node2: | ||
build: | ||
context: ../../../ | ||
dockerfile: ./Dockerfile | ||
container_name: node2 | ||
command: ["./target/debug/memstore-dynamic-members", "--raft-addr=node2:60062", "--web-server=0.0.0.0:8002", "--peer-addr=node1:60061"] | ||
ports: | ||
- "8002:8002" | ||
expose: | ||
- "8002" | ||
depends_on: | ||
- node1 | ||
|
||
node3: | ||
build: | ||
context: ../../../ | ||
dockerfile: ./Dockerfile | ||
container_name: node3 | ||
command: ["./target/debug/memstore-dynamic-members", "--raft-addr=node3:60063", "--web-server=0.0.0.0:8003", "--peer-addr=node1:60061"] | ||
ports: | ||
- "8003:8003" | ||
expose: | ||
- "8003" | ||
depends_on: | ||
- node2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# Docker-compose example for running a 3-node cluster. | ||
services: | ||
node1: | ||
build: | ||
context: ../../../ | ||
dockerfile: ./Dockerfile | ||
container_name: node1 | ||
entrypoint: ["/bin/sh","-c"] | ||
command: | ||
- | | ||
./misc/generate-static-cluster-config.sh node1 node2 node3 > ./examples/memstore/static-members/cluster_config.toml | ||
./target/debug/memstore-static-members --raft-addr=node1:60061 --web-server=0.0.0.0:8001 | ||
ports: | ||
- "8001:8001" | ||
expose: | ||
- "8001" | ||
|
||
node2: | ||
build: | ||
context: ../../../ | ||
dockerfile: ./Dockerfile | ||
container_name: node2 | ||
entrypoint: ["/bin/sh","-c"] | ||
command: | ||
- | | ||
./misc/generate-static-cluster-config.sh node1 node2 node3 > ./examples/memstore/static-members/cluster_config.toml | ||
./target/debug/memstore-static-members --raft-addr=node2:60062 --web-server=0.0.0.0:8002 | ||
ports: | ||
- "8002:8002" | ||
expose: | ||
- "8002" | ||
|
||
node3: | ||
build: | ||
context: ../../../ | ||
dockerfile: ./Dockerfile | ||
container_name: node3 | ||
entrypoint: ["/bin/sh","-c"] | ||
command: | ||
- | | ||
./misc/generate-static-cluster-config.sh node1 node2 node3 > ./examples/memstore/static-members/cluster_config.toml | ||
./target/debug/memstore-static-members --raft-addr=node3:60063 --web-server=0.0.0.0:8003 | ||
ports: | ||
- "8003:8003" | ||
expose: | ||
- "8003" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
# Generate `cluster_config.toml` used in static bootstrap example. | ||
# Used in `docker-compose.yml` of the static members example. | ||
|
||
if [ "$#" -lt 1 ]; then | ||
echo "Usage: $0 addr1 addr2 addr3 ..." | ||
exit 1 | ||
fi | ||
|
||
port=60061 | ||
node_id=1 | ||
|
||
for ip in "$@" | ||
do | ||
echo "[[raft.peers]]" | ||
echo "ip = \"$ip\"" | ||
echo "port = $port" | ||
echo "node_id = $node_id" | ||
echo "role = \"voter\"" | ||
echo "" | ||
|
||
port=$((port + 1)) | ||
node_id=$((node_id + 1)) | ||
done |