Skip to content

Commit

Permalink
update: docker stuff for file sharing demo
Browse files Browse the repository at this point in the history
  • Loading branch information
sacha-l committed May 16, 2024
1 parent ff02d2b commit cd8b1fa
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
8 changes: 4 additions & 4 deletions tutorials/file_sharing_app/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ COPY . .
# Build the Rust crate
RUN cargo build --release

# Run the first node
CMD ["cargo", "run", "--release", "--features=first-node"]
# Run the script to start both nodes
COPY run_both_nodes.sh .
RUN chmod +x run_both_nodes.sh

# Run the second node after the first one completes
CMD ["cargo", "run", "--release", "--features=second-node"]
CMD ["./run_both_nodes.sh"]
4 changes: 3 additions & 1 deletion tutorials/file_sharing_app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ A 5 second timeout is set to give enough time for the nodes to communicate with

> This example uses `async-std-runtime` specified in the crate's Cargo.toml file to demonsrate SwarmNl's compatibility with using the async-std runtime.
**Note:** The example requires a quorum of 1, which means that that if the second node does not run the first node will not be able to write to the DHT and will panic.

## Run the example

To run this example, you'll need two terminals.
Expand Down Expand Up @@ -94,4 +96,4 @@ Run:
```bash
docker run -it file-sharing-demo
```
```
9 changes: 9 additions & 0 deletions tutorials/file_sharing_app/run_both_nodes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# Used for the Docker container to run both nodes

# Run the first command in the background
cargo run --features=first-node &

# Run the second command in the foreground
cargo run --features=second-node

0 comments on commit cd8b1fa

Please sign in to comment.