From e435dfba36397d6a12eb6b31cea24e0a74a8ea25 Mon Sep 17 00:00:00 2001 From: Neotamandua <107320179+Neotamandua@users.noreply.github.com> Date: Thu, 28 Nov 2024 18:09:00 +0200 Subject: [PATCH] rusk: change Dockerfile & workflow to run with archive - add CARGO_FEATURES build-arg to Dockerfile - change README to include new docker build command - adjust workflow to use "archive" build-arg - small improvement on Makefile commands --- .github/workflows/docker_image_build.yml | 2 +- Dockerfile | 11 ++++++++++- Makefile | 8 ++++++-- README.md | 7 ++++++- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker_image_build.yml b/.github/workflows/docker_image_build.yml index 59993c300a..a3f4099441 100644 --- a/.github/workflows/docker_image_build.yml +++ b/.github/workflows/docker_image_build.yml @@ -15,7 +15,7 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Build Docker image - run: docker build -t rusk . + run: docker build -t rusk --build-arg CARGO_FEATURES="archive" . - name: Save Docker image run: docker save rusk:latest -o rusk_image.tar diff --git a/Dockerfile b/Dockerfile index 4e29561d16..9bbcc17bec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,6 +12,10 @@ ARG TARGETPLATFORM # See also https://github.com/docker/buildx/issues/510 ENV TARGETPLATFORM=${TARGETPLATFORM:-linux/amd64} +# Features to include in the build +# E.g., --build-arg CARGO_FEATURES="archive" +ARG CARGO_FEATURES="" + # Convert Docker platform arg to Rust target name, # and install nightly based on the Rust target RUN ARCH="$(echo $TARGETPLATFORM | sed 's/linux\///')" && \ @@ -29,7 +33,12 @@ RUN ARCH="$(echo $TARGETPLATFORM | sed 's/linux\///')" && \ # Generate keys and compile genesis contracts RUN make keys RUN make wasm -RUN cargo b --release -p rusk +# Build rusk with default features and include CARGO_FEATURES +RUN if [ -n "$CARGO_FEATURES" ]; then \ + cargo build --release --features "$CARGO_FEATURES" -p rusk; \ + else \ + cargo build --release -p rusk; \ + fi # --- Run stage --- FROM debian:bookworm-slim diff --git a/Makefile b/Makefile index c47c16460e..cfbadb88b2 100644 --- a/Makefile +++ b/Makefile @@ -74,10 +74,14 @@ prepare-dev: keys wasm ## Preparation steps for launching a local node for devel && cargo r --release -p rusk -- recovery state --init examples/genesis.toml -o /tmp/example.state || echo "Example genesis state already exists. Not overriding it" run-dev: ## Launch a local ephemeral node for development - DUSK_CONSENSUS_KEYS_PASS=password cargo r --release -p rusk -- -s /tmp/example.state + @echo "Starting a local ephemeral node for development (without archive)" && \ + DUSK_CONSENSUS_KEYS_PASS=password cargo r --release -p rusk -- -s /tmp/example.state || \ + echo "Failed to start the node. Make sure you have run 'make prepare-dev' before running this command" run-dev-archive: ## Launch a local ephemeral archive node for development - DUSK_CONSENSUS_KEYS_PASS=password cargo r --release --features archive -p rusk -- -s /tmp/example.state + @echo "Starting a local ephemeral archive node for development" && \ + DUSK_CONSENSUS_KEYS_PASS=password cargo r --release --features archive -p rusk -- -s /tmp/example.state || \ + echo "Failed to start the node. Make sure you have run 'make prepare-dev' before running this command" rusk: keys state web-wallet ## Build rusk binary $(MAKE) -C ./rusk build diff --git a/README.md b/README.md index 654bd2b8e5..fe1182bcdc 100644 --- a/README.md +++ b/README.md @@ -115,12 +115,17 @@ See also `make help` for all the available commands It's also possible to run a local ephemeral node with Docker. -To build the Docker image: +To build the Docker image without archive: ```bash docker build -t rusk . ``` +To build the Docker image with archive: +```bash +docker build -t rusk --build-arg CARGO_FEATURES="archive" . +``` + To run Rusk inside a Docker container: ```bash