From c720e8d41c93640b7f2b67a1e63ef0010bb39eb5 Mon Sep 17 00:00:00 2001 From: Lyn <0xlynett@proton.me> Date: Thu, 4 Apr 2024 17:42:56 +0000 Subject: [PATCH] Dockerize Kinode (todo: use a different account other than my personal one as the namespace) --- .dockerignore | 23 +++++++++++++++++++++++ Dockerfile | 32 ++++++++++++++++++++++++++++++++ README.md | 22 ++++++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..061e359b --- /dev/null +++ b/.dockerignore @@ -0,0 +1,23 @@ +target/ +wit/ +**/target/ +**/wit/ +**/*.wasm +.vscode +.app-signing +.DS_Store +*.swp +*.swo +*.zip +/home +packages/**/pkg/*.wasm +packages/**/wit +*/**/node_modules +.env +kinode/src/bootstrapped_processes.rs +kinode/packages/**/wasi_snapshot_preview1.wasm + +LICENSE +pull_request_template.md +README.md +Dockerfile \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..1a6c7b2d --- /dev/null +++ b/Dockerfile @@ -0,0 +1,32 @@ +# syntax=docker/dockerfile:1 +FROM rust AS builder + +COPY . /tmp/source + +WORKDIR /tmp/source + +RUN apt-get update +RUN apt-get install clang -y + +RUN cargo install wasm-tools && \ + rustup install nightly && \ + rustup target add wasm32-wasi && \ + rustup target add wasm32-wasi --toolchain nightly && \ + cargo install cargo-wasi + +RUN cargo +nightly build -p kinode --release + +FROM debian:12-slim + +RUN apt-get update +RUN apt-get install openssl -y + +COPY --from=builder /tmp/source/target/release/kinode /bin/kinode + +ENV LD_LIBRARY_PATH=/lib +ENV RUST_BACKTRACE=full +ENTRYPOINT [ "/bin/kinode" ] +CMD [ "/kinode" ] + +EXPOSE 8080 +EXPOSE 9000 \ No newline at end of file diff --git a/README.md b/README.md index a5ef37b6..15d24edc 100644 --- a/README.md +++ b/README.md @@ -134,3 +134,25 @@ Download and install an app: m our@main:app_store:sys '{"Download": {"package": {"package_name": "", "publisher_node": ""}, "install_from": ""}}' m our@main:app_store:sys '{"Install": {"package_name": "", "publisher_node": ""}}' ``` + +## Running as a Docker container + +This image expects a volume mounted at `/kinode`. This volume may be empty or may contain another Kinode's data. It will be used as the home directory of your Kinode. + +The image includes EXPOSE directives for TCP port `8080` and TCP port `9000`. Port `8080` is used for serving the Kinode web dashboard over HTTP, and it may be mapped to a different port on the host. Port `9000` is optional and is only required for a direct node. + +If you are running a direct node, you must map port `9000` to the same port on the host and on your router. Otherwise, your Kinode will not be able to connect to the rest of the network as connection info is written to the chain, and this information is based on the view from inside the Docker container. + +To build a local Docker image, run the following command in this project root. +``` +docker build -t 0xlynett/kinode . +``` + +For example: +``` +docker volume create kinode-volume + +docker run -d -p 8080:8080 -it --name my-kinode \ + --mount type=volume,source=kinode-volume,destination=/kinode \ + 0xlynett/kinode +``` \ No newline at end of file