Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

protocols/relay: Simplify running the relay example #2080

Merged
merged 26 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
349d5fb
protocols/relay: Simplify running the relay example
r-zig May 26, 2021
83ee2c2
Resolve secret_key_seed name suggestion
r-zig May 29, 2021
533ec5d
Delete .dockerignore
r-zig May 29, 2021
650da57
Update Cargo.toml
r-zig May 29, 2021
abaf86f
Update protocols/relay/examples/docker-compose.yml
r-zig May 29, 2021
b0c8013
remove placeholder for discovery mechanism
r-zig May 29, 2021
99833ab
Use DNS instead of IP
r-zig Jun 8, 2021
1a7e237
remove hex from cargo.tomp
r-zig Jun 8, 2021
a736295
use DNS instead of IP addresses
r-zig Jun 9, 2021
644eba7
Update protocols/relay/examples/Dockerfile
r-zig Jun 10, 2021
a2f742d
remove RUN USER=root cargo new rust-libp2p
r-zig Jun 11, 2021
c0509c6
Merge branch 'master' into add-docker-to-relay-example
r-zig Jun 11, 2021
533e4a8
Merge branch 'master' into add-docker-to-relay-example
r-zig Jun 14, 2021
d727332
Simulate different network for client dial and client listen.
r-zig Jun 18, 2021
51ebd5d
Merge branch 'add-docker-to-relay-example' of https://github.com/r-zi…
r-zig Jun 18, 2021
86a685a
Merge branch 'master' into add-docker-to-relay-example
r-zig Jun 19, 2021
76c5e60
Print all peers events.
r-zig Jun 19, 2021
33c3de9
separate between ipv4 and ipv6 examples
r-zig Jun 25, 2021
1625539
remove default docker-compose.yml
r-zig Jun 25, 2021
23b0e12
Merge branch 'master' into add-docker-to-relay-example
r-zig Jun 28, 2021
1a593e1
downgrade docker-compose version to 2.1
r-zig Jun 29, 2021
c0452b6
remove docker-compose.ipv4 to simplify the example
r-zig Jun 29, 2021
39a7e20
Merge branch 'add-docker-to-relay-example' of https://github.com/r-zi…
r-zig Jun 29, 2021
a3bbedb
Merge branch 'master' into add-docker-to-relay-example
r-zig Jun 29, 2021
09d41d5
protocols/relay/examples/docker-compose.yml: Remove outdated comment
mxinden Jun 30, 2021
7f13d07
Merge branch 'master' into add-docker-to-relay-example
mxinden Jun 30, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
**/.classpath
r-zig marked this conversation as resolved.
Show resolved Hide resolved
**/.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
2 changes: 2 additions & 0 deletions protocols/relay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ prost-build = "0.7"

[dev-dependencies]
env_logger = "0.8.3"
hex = "0.4.2"
r-zig marked this conversation as resolved.
Show resolved Hide resolved
structopt = "0.3.21"
libp2p = { path = "../.." }
libp2p-kad = { path = "../kad" }
libp2p-ping = { path = "../ping" }
Expand Down
22 changes: 22 additions & 0 deletions protocols/relay/examples/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 1: Build the exe
FROM rust:latest as builder
r-zig marked this conversation as resolved.
Show resolved Hide resolved
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
r-zig marked this conversation as resolved.
Show resolved Hide resolved

# 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
56 changes: 56 additions & 0 deletions protocols/relay/examples/docker-compose.yml
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

r-zig marked this conversation as resolved.
Show resolved Hide resolved
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
r-zig marked this conversation as resolved.
Show resolved Hide resolved
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
Loading