From 9bbbc92d1b1cb12c71d172b77683921e9d3cd9d6 Mon Sep 17 00:00:00 2001 From: Miguel Medeiros Date: Mon, 4 Nov 2024 12:52:41 -0300 Subject: [PATCH] feat: add Dockerfile and update README for Docker setup --- Dockerfile | 29 +++++++++++++++++++++++++++++ README.md | 18 ++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..61fb2db --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +# Start with an official Rust image +FROM rust:latest as builder + +# Create a new directory for the project +WORKDIR /usr/src/pkarr-server + +# Copy the project files into the container +COPY . . + +# Build the project in release mode +RUN cargo build --release + +# Use an image with a compatible glibc version +FROM ubuntu:latest + +# Install necessary libraries +RUN apt-get update && apt-get install -y libssl-dev + +# Copy the binary from the builder stage +COPY --from=builder /usr/src/pkarr-server/target/release/pkarr-server /usr/local/bin/pkarr-server + +# Copy the example configuration file as config.toml if config.toml is not present +COPY --from=builder /usr/src/pkarr-server/server/src/config.example.toml /etc/pkarr/config.toml + +# Expose the necessary port (change according to your server settings) +EXPOSE 6881 + +# Run the server with the appropriate flags +CMD ["pkarr-server", "--config=/etc/pkarr/config.toml", "-t=pkarr=debug,tower_http=debug"] \ No newline at end of file diff --git a/README.md b/README.md index a0b6d14..0676798 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,21 @@ Try the [web app demo](https://app.pkarr.org). Or if you prefer Rust [Examples](./pkarr/examples) +## Docker Setup +To build and run the Pkarr server using Docker, follow these steps: + +1. **Build the Docker image**: +```bash +docker build -t pkarr-server . +``` + +2. Run the Docker container: +```bash +docker run -p 6881:6881 --name pkarr-server-container pkarr-server +``` + +This will make the Pkarr server accessible at http://localhost:6881. + ## TOC - [Architecture](#Architecture) - [Expectations](#Expectations) @@ -158,3 +173,6 @@ Open social networks often attempt to solve discovery natively within their netw - Their infrastructure would need to become a gossip overlay network, which may not be desirable. - Achieving consistency and load balancing would require further optimization, effectively reinventing a DHT. - If an overlay network is developed that surpasses the performance of a 10-million-node DHT with a 15-year track record, Pkarr should still be capable of utilizing your network as a backend, either as an alternative or alongside existing solutions. + +3. **How can I run the Pkarr server using Docker?** + To run the server with Docker, build the image and start the container using the instructions in the [Docker Setup](#docker-setup) section.