From 4e58f750fc861583939fc25ec3c0ef9224968611 Mon Sep 17 00:00:00 2001 From: kaichaosun Date: Tue, 28 Jul 2026 18:09:40 +0800 Subject: [PATCH] chore: update docker file for exposed port --- Dockerfile | 4 +++- README.md | 19 ++++++++++++++----- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0785206..ad58cf2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -68,10 +68,12 @@ COPY --from=builder /output/chat-store /usr/local/bin/chat-store # Matches the default --bind 0.0.0.0:8080. EXPOSE 8080 +EXPOSE 60000/tcp +EXPOSE 60000/udp # Persist the SQLite database on a volume rather than the container layer. VOLUME ["/data"] ENV RUST_LOG=info ENTRYPOINT ["chat-store"] -CMD ["--bind", "0.0.0.0:8080", "--db", "/data/chat-store.db"] +CMD ["--bind", "0.0.0.0:8080", "--db", "/data/chat-store.db", "--p2p-port", "60000"] diff --git a/README.md b/README.md index ab322b1..f3f8d4f 100644 --- a/README.md +++ b/README.md @@ -108,8 +108,10 @@ topics when constructed with `RegistryPublishMode::Delivery`. # Build the image docker build -t chat-store . -# Run it, persisting the SQLite db on a named volume and exposing port 8080 -docker run --rm -p 8080:8080 -v chat-store-data:/data chat-store +# Run it, persisting the SQLite db on a named volume. 8080 is the HTTP API; +# 60000 is the delivery node's libp2p (TCP) and discv5 (UDP) port. +docker run --rm -p 8080:8080 -p 60000:60000/tcp -p 60000:60000/udp \ + -v chat-store-data:/data chat-store ``` The build runs inside nix, because the binary links `liblogosdelivery` and the @@ -119,14 +121,21 @@ carrying only the nix store closure the binary resolves by absolute path. The first build compiles the native library from source and takes a long time; afterwards it is a cached layer that only changes with `flake.lock`. -The image runs the binary with `--bind 0.0.0.0:8080 --db /data/chat-store.db` -by default; override the `CMD` to change flags, e.g.: +The image runs the binary with +`--bind 0.0.0.0:8080 --db /data/chat-store.db --p2p-port 60000` by default. The +p2p port is pinned rather than left at its default of `0`, because an +OS-assigned port cannot be published from a container and would leave the node +undialable. Override the `CMD` to change flags, e.g.: ```bash docker run --rm -p 9000:9000 -v chat-store-data:/data chat-store \ - --bind 0.0.0.0:9000 --db /data/registry.db --retention-days 14 + --bind 0.0.0.0:9000 --db /data/registry.db --retention-days 14 --no-delivery ``` +Note that overriding `CMD` replaces it wholesale, so a delivery-enabled run has +to repeat `--p2p-port`. Deployments that only serve the HTTP API can pass +`--no-delivery` and skip publishing the p2p ports entirely. + ## API ### `POST /v0/keypackage`