From 488ea5091448d81879a7e784ccc0c43b5154d747 Mon Sep 17 00:00:00 2001 From: qiqi Date: Wed, 24 Apr 2024 09:41:31 +0800 Subject: [PATCH 1/4] Add Dockerfile --- .dockerignore | 5 +++++ Dockerfile | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 .dockerignore create mode 100644 Dockerfile diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 000000000..315f4803a --- /dev/null +++ b/.dockerignore @@ -0,0 +1,5 @@ +.git +.github +.gitignore + +Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 000000000..4ab20344a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,31 @@ +FROM rust:bookworm AS builder + +RUN apt-get update +RUN apt-get install -y curl git build-essential libssl-dev pkg-config +RUN apt-get install -y protobuf-compiler libprotobuf-dev +RUN apt-get install -y clang-format clang-tidy \ + clang-tools clang clangd libc++-dev \ + libc++1 libc++abi-dev libc++abi1 \ + libclang-dev libclang1 liblldb-dev \ + libllvm-ocaml-dev libomp-dev libomp5 \ + lld lldb llvm-dev llvm-runtime \ + llvm python3-clang + +RUN cargo install wasm-pack +RUN rustup target add wasm32-unknown-unknown + +COPY . /rusty-kaspa +WORKDIR /rusty-kaspa +RUN cargo build --release + + +FROM debian:bookworm + +COPY --from=builder /rusty-kaspa/target/release/kaspad /usr/bin/ +COPY --from=builder /rusty-kaspa/target/release/kaspa-wallet /usr/bin/ +COPY --from=builder /rusty-kaspa/target/release/kaspa_p2p_client /usr/bin/ +COPY --from=builder /rusty-kaspa/target/release/kaspa_p2p_server /usr/bin/ +COPY --from=builder /rusty-kaspa/target/release/kaspa_p2p_server /usr/bin/ +COPY --from=builder /rusty-kaspa/target/release/kaspa-wrpc-proxy /usr/bin/ +COPY --from=builder /rusty-kaspa/target/release/simpa /usr/bin/ +COPY --from=builder /rusty-kaspa/target/release/rothschild /usr/bin/ From 9993fc2822cba2ae818670ea983590428b2fe9f3 Mon Sep 17 00:00:00 2001 From: qiqi Date: Wed, 24 Apr 2024 14:13:12 +0800 Subject: [PATCH 2/4] Add target to .dockerignore && update Dockerfile --- .dockerignore | 1 + Dockerfile | 7 +------ 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.dockerignore b/.dockerignore index 315f4803a..fa8be62bb 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,3 +3,4 @@ .gitignore Dockerfile +target diff --git a/Dockerfile b/Dockerfile index 4ab20344a..d742ff086 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ RUN apt-get install -y clang-format clang-tidy \ RUN cargo install wasm-pack RUN rustup target add wasm32-unknown-unknown +# TODO cache build dependencies COPY . /rusty-kaspa WORKDIR /rusty-kaspa RUN cargo build --release @@ -23,9 +24,3 @@ FROM debian:bookworm COPY --from=builder /rusty-kaspa/target/release/kaspad /usr/bin/ COPY --from=builder /rusty-kaspa/target/release/kaspa-wallet /usr/bin/ -COPY --from=builder /rusty-kaspa/target/release/kaspa_p2p_client /usr/bin/ -COPY --from=builder /rusty-kaspa/target/release/kaspa_p2p_server /usr/bin/ -COPY --from=builder /rusty-kaspa/target/release/kaspa_p2p_server /usr/bin/ -COPY --from=builder /rusty-kaspa/target/release/kaspa-wrpc-proxy /usr/bin/ -COPY --from=builder /rusty-kaspa/target/release/simpa /usr/bin/ -COPY --from=builder /rusty-kaspa/target/release/rothschild /usr/bin/ From d104977f599e1816df507dd49259361b031a4ec1 Mon Sep 17 00:00:00 2001 From: qiqi Date: Fri, 26 Apr 2024 17:41:58 +0800 Subject: [PATCH 3/4] Remove curl&git when build --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d742ff086..9391a2f7d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,7 @@ FROM rust:bookworm AS builder RUN apt-get update -RUN apt-get install -y curl git build-essential libssl-dev pkg-config +RUN apt-get install -y build-essential libssl-dev pkg-config RUN apt-get install -y protobuf-compiler libprotobuf-dev RUN apt-get install -y clang-format clang-tidy \ clang-tools clang clangd libc++-dev \ From a7d22972856e9dca2a9f2f7e39aca6ba72e597ba Mon Sep 17 00:00:00 2001 From: qiqi Date: Mon, 29 Apr 2024 18:01:21 +0800 Subject: [PATCH 4/4] Add CMD in Dockerfile & Update README.md --- Dockerfile | 2 ++ README.md | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/Dockerfile b/Dockerfile index 9391a2f7d..50f0f195a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,3 +24,5 @@ FROM debian:bookworm COPY --from=builder /rusty-kaspa/target/release/kaspad /usr/bin/ COPY --from=builder /rusty-kaspa/target/release/kaspa-wallet /usr/bin/ + +CMD kaspad diff --git a/README.md b/README.md index be552c678..a0daad603 100644 --- a/README.md +++ b/README.md @@ -235,6 +235,22 @@ The framework is compatible with all major desktop and mobile browsers. +
+Building on Docker + +You can also use Docker to build binaries. +``` +docker build -t kaspa-rusty . +``` + +Then you can run kaspad using. +``` +docker run --rm -it kaspa-rusty:latest +``` + +
+ + ## Running the node **Start a mainnet node**