forked from libp2p/rust-libp2p
-
Notifications
You must be signed in to change notification settings - Fork 0
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
with all peers run together via docker compose libp2p#2052
- Loading branch information
Showing
5 changed files
with
335 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
**/.classpath | ||
**/.dockerignore | ||
**/.env | ||
**/.git | ||
**/.gitignore | ||
**/.project | ||
**/.settings | ||
**/.toolstarget | ||
**/.vs | ||
**/.vscode | ||
**/*.*proj.user | ||
**/*.dbmdl | ||
**/*.jfm | ||
**/azds.yaml | ||
**/bin | ||
**/charts | ||
**/docker-compose* | ||
**/compose* | ||
**/Dockerfile* | ||
**/node_modules | ||
**/npm-debug.log | ||
**/obj | ||
**/secrets.dev.yaml | ||
**/values.dev.yaml | ||
README.md | ||
**/target | ||
**/Cargo.lock | ||
**/docker-compose.debug.yml | ||
**/docker-compose.yml |
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,22 @@ | ||
# 1: Build the exe | ||
FROM rust:latest 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) | ||
RUN USER=root cargo new rust-libp2p | ||
WORKDIR /usr/src/libp2p | ||
|
||
COPY . /usr/src/libp2p | ||
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 | ||
|
||
ENTRYPOINT ./relay -d $deterministic_peer_env --mode $relay_command_arg_env --address $address_env |
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,56 @@ | ||
version: '3.4' | ||
services: | ||
relay: | ||
image: libp2p-relay | ||
environment: | ||
- relay_command_arg_env=relay | ||
- deterministic_peer_env=1 | ||
# - address_env=/ip4/0.0.0.0/tcp/4444 | ||
- address_env=/ip6/2001:3984:3989::10/tcp/4444 | ||
build: | ||
context: ../../../. | ||
dockerfile: ./protocols/relay/examples/Dockerfile | ||
networks: | ||
default: | ||
ipv4_address: 172.16.238.10 | ||
ipv6_address: 2001:3984:3989::10 | ||
|
||
client-listen: | ||
image: libp2p-relay | ||
environment: | ||
- relay_command_arg_env=client-listen | ||
- deterministic_peer_env=2 | ||
# - address_env=/ip4/172.16.238.10/tcp/4444/p2p/12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X/p2p-circuit | ||
- address_env=/ip6/2001:3984:3989::10/tcp/4444/p2p/12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X/p2p-circuit | ||
build: | ||
context: ../../../. | ||
dockerfile: ./protocols/relay/examples/Dockerfile | ||
networks: | ||
default: | ||
ipv4_address: 172.16.238.11 | ||
ipv6_address: 2001:3984:3989::11 | ||
client-dial: | ||
image: libp2p-relay | ||
environment: | ||
- relay_command_arg_env=client-dial | ||
- deterministic_peer_env=3 | ||
# - address_env=/ip4/172.16.238.10/tcp/4444/p2p/12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X/p2p-circuit/p2p/12D3KooWH3uVF6wv47WnArKHk5p6cvgCJEb74UTmxztmQDc298L3 | ||
- address_env=/ip6/2001:3984:3989::10/tcp/4444/p2p/12D3KooWPjceQrSwdWXPyLLeABRXmuqt69Rg3sBYbU1Nft9HyQ6X/p2p-circuit/p2p/12D3KooWH3uVF6wv47WnArKHk5p6cvgCJEb74UTmxztmQDc298L3 | ||
build: | ||
context: ../../../. | ||
dockerfile: ./protocols/relay/examples/Dockerfile | ||
networks: | ||
default: | ||
ipv4_address: 172.16.238.12 | ||
ipv6_address: 2001:3984:3989::12 | ||
networks: | ||
default: | ||
driver: bridge | ||
enable_ipv6: true | ||
ipam: | ||
driver: default | ||
config: | ||
- subnet: 172.16.238.0/24 | ||
gateway: 172.16.238.1 | ||
- subnet: 2001:3984:3989::/64 | ||
gateway: 2001:3984:3989::1 |
Oops, something went wrong.