Skip to content

Commit

Permalink
rusk: change Dockerfile & workflow to run with archive
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
Neotamandua committed Nov 28, 2024
1 parent da006b5 commit e435dfb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docker_image_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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\///')" && \
Expand All @@ -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
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e435dfb

Please sign in to comment.