-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
protocols/relay: Simplify running the relay example (#2080)
Simplify running the relay example with all peers run via docker compose. Co-authored-by: Max Inden <mail@max-inden.de>
- Loading branch information
Showing
4 changed files
with
242 additions
and
51 deletions.
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
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,19 @@ | ||
# 1: Build the exe | ||
FROM rust:1 as builder | ||
LABEL Name=libp2p-relay Version=0.0.1 | ||
# 1a: Prepare for static linking | ||
RUN apt-get update && \ | ||
apt-get dist-upgrade -y && \ | ||
apt-get install -y musl-tools && \ | ||
rustup target add x86_64-unknown-linux-musl | ||
# 1b: Download and compile Rust dependencies (and store as a separate Docker layer) | ||
WORKDIR /usr/src/libp2p | ||
|
||
COPY . . | ||
RUN cargo build --target x86_64-unknown-linux-musl --example=relay --package=libp2p-relay | ||
|
||
# 2: Copy the exe and extra files ("static") to an empty Docker image | ||
FROM debian:buster-slim | ||
|
||
COPY --from=builder /usr/src/libp2p/target/x86_64-unknown-linux-musl/debug/examples/relay . | ||
USER 1000 |
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,63 @@ | ||
# Run `docker-compose up` to start the setup. | ||
|
||
version: '2.1' | ||
services: | ||
relay: | ||
image: libp2p-relay | ||
command: | ||
- "./relay" | ||
- "--mode=relay" | ||
- "--secret-key-seed=1" | ||
- "--address=/ip6/::/tcp/4444" | ||
build: | ||
context: ../../../. | ||
dockerfile: ./protocols/relay/examples/Dockerfile | ||
networks: | ||
- network-a | ||
- network-b | ||
|
||
client-listen: | ||
image: libp2p-relay | ||
command: | ||
- "./relay" | ||
- "--mode=client-listen" | ||
- "--secret-key-seed=2" | ||
- "--address=/dns6/relay/tcp/4444/p2p/12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X/p2p-circuit" | ||
build: | ||
context: ../../../. | ||
dockerfile: ./protocols/relay/examples/Dockerfile | ||
depends_on: | ||
- "relay" | ||
networks: | ||
- network-a | ||
|
||
client-dial: | ||
image: libp2p-relay | ||
command: | ||
- "./relay" | ||
- "--mode=client-dial" | ||
- "--secret-key-seed=3" | ||
- "--address=/dns6/relay/tcp/4444/p2p/12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X/p2p-circuit/p2p/12D3KooWH3uVF6wv47WnArKHk5p6cvgCJEb74UTmxztmQDc298L3" | ||
build: | ||
context: ../../../. | ||
dockerfile: ./protocols/relay/examples/Dockerfile | ||
depends_on: | ||
- "client-listen" | ||
networks: | ||
- network-b | ||
|
||
networks: | ||
network-a: | ||
driver: bridge | ||
enable_ipv6: true | ||
ipam: | ||
driver: default | ||
config: | ||
- subnet: 2001:3984:3989::/64 | ||
network-b: | ||
driver: bridge | ||
enable_ipv6: true | ||
ipam: | ||
driver: default | ||
config: | ||
- subnet: 2001:3984:3988::/64 |
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