From ce8f38cc161f2a3bb4b74458baf7e53bba62fa6e Mon Sep 17 00:00:00 2001 From: Mario Camou Date: Mon, 11 Sep 2023 18:51:54 +0200 Subject: [PATCH] feat(misc/server): add `libp2p-lookup` to `rust-libp2p-server` As mentioned in #4444, we need to include https://github.com/mxinden/libp2p-lookup/ in the image so that we can enable a healthcheck when it starts up. Pull-Request: #4466. --- Cargo.lock | 2 +- Cargo.toml | 2 +- misc/server/CHANGELOG.md | 4 ++++ misc/server/Cargo.toml | 2 +- misc/server/Dockerfile | 8 ++++++-- misc/server/README.md | 6 ++++++ 6 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5f5c4fa3114..e49ec51f6ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3155,7 +3155,7 @@ dependencies = [ [[package]] name = "libp2p-server" -version = "0.12.2" +version = "0.12.3" dependencies = [ "base64 0.21.3", "clap", diff --git a/Cargo.toml b/Cargo.toml index 155b25771e5..55258267fec 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -91,7 +91,7 @@ libp2p-quic = { version = "0.9.2", path = "transports/quic" } libp2p-relay = { version = "0.16.1", path = "protocols/relay" } libp2p-rendezvous = { version = "0.13.0", path = "protocols/rendezvous" } libp2p-request-response = { version = "0.25.1", path = "protocols/request-response" } -libp2p-server = { version = "0.12.2", path = "misc/server" } +libp2p-server = { version = "0.12.3", path = "misc/server" } libp2p-swarm = { version = "0.43.4", path = "swarm" } libp2p-swarm-derive = { version = "0.33.0", path = "swarm-derive" } libp2p-swarm-test = { version = "0.2.0", path = "swarm-test" } diff --git a/misc/server/CHANGELOG.md b/misc/server/CHANGELOG.md index 8bb5768822c..d7c8f71d033 100644 --- a/misc/server/CHANGELOG.md +++ b/misc/server/CHANGELOG.md @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.12.3] - unreleased +### Changed +- Add libp2p-lookup to Dockerfile to enable healthchecks. + ## [0.12.2] ### Fixed - Adhere to `--metrics-path` flag and listen on `0.0.0.0:8888` (default IPFS metrics port). diff --git a/misc/server/Cargo.toml b/misc/server/Cargo.toml index 32b815c407a..aa259ce8214 100644 --- a/misc/server/Cargo.toml +++ b/misc/server/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libp2p-server" -version = "0.12.2" +version = "0.12.3" authors = ["Max Inden "] edition = "2021" repository = "https://github.com/libp2p/rust-libp2p" diff --git a/misc/server/Dockerfile b/misc/server/Dockerfile index 34f0c7d0bf9..72641cc3b2e 100644 --- a/misc/server/Dockerfile +++ b/misc/server/Dockerfile @@ -1,8 +1,12 @@ -FROM rust:1.66-bullseye as builder +FROM rust:1.72-bullseye as builder WORKDIR /usr/src/rust-libp2p-server # Run with access to the target cache to speed up builds WORKDIR /workspace + +RUN --mount=type=cache,target=/usr/local/cargo/registry \ + cargo install --locked --root /usr/local libp2p-lookup --version 0.6.4 + ADD . . RUN --mount=type=cache,target=./target \ --mount=type=cache,target=/usr/local/cargo/registry \ @@ -12,5 +16,5 @@ RUN --mount=type=cache,target=./target \ mv ./target/release/libp2p-server /usr/local/bin/libp2p-server FROM gcr.io/distroless/cc -COPY --from=builder /usr/local/bin/libp2p-server /usr/local/bin/libp2p-server +COPY --from=builder /usr/local/bin/libp2p-server /usr/local/bin/libp2p-lookup /usr/local/bin/ CMD ["libp2p-server"] diff --git a/misc/server/README.md b/misc/server/README.md index ec4012562a2..0da1bd8abd9 100644 --- a/misc/server/README.md +++ b/misc/server/README.md @@ -33,3 +33,9 @@ Local peer id: PeerId("12D3KooWSa1YEeQVSwvoqAMhwjKQ6kqZQckhWPb3RWEGV3sZGU6Z") Listening on "/ip4/127.0.0.1/udp/4001/quic" [...] ``` + +The Docker container includes [libp2-lookup](https://github.com/mxinden/libp2p-lookup/) to enable adding a proper healthcheck for container startup, e.g. + +``` shell +docker run --health-cmd 'libp2p-lookup direct --address /ip4/127.0.0.1/tcp/4001/p2p/QmQCU2EcMqAqQPR2i9bChDtGNJchTbq5TbXJJ16u19uLTa' /home/ipfs/.ipfs:/ipfs ghcr.io/libp2p/rust-libp2p-server --config /ipfs/config +```