Skip to content

Commit

Permalink
feat: update templates and Dockerfile to support Zombienet (#587)
Browse files Browse the repository at this point in the history
Zombienet uses the empty chainspec for a parachain, and that was not
supported by the node templates. Also, the Dockerfile assumes the
`kilt-parachain` is being run, but this is different now, and could also
be different in the future, so the binary target should be parametrized:
anyway, it is not necessary to compile the whole workspace if only a
specific binary is required.
  • Loading branch information
ntn-x2 authored Nov 27, 2023
1 parent 8b448aa commit 66b46be
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,21 @@ FROM paritytech/ci-unified:bullseye-1.70.0 as builder
WORKDIR /build

ARG FEATURES=default
ARG BINARY=kilt-parachain

COPY . .

RUN cargo build --locked --release --features $FEATURES
RUN cargo build --locked --release --features $FEATURES -p $BINARY

# ===== SECOND STAGE ======

FROM docker.io/library/ubuntu:20.04
LABEL description="This is the 2nd stage: a very small image where we copy the kilt-parachain binary."

ARG NODE_TYPE=kilt-parachain
ARG BINARY=kilt-parachain

COPY --from=builder /build/target/release/$NODE_TYPE /usr/local/bin/node-executable
LABEL description="This is the 2nd stage: a very small image where we copy the ${BINARY} binary."

COPY --from=builder /build/target/release/$BINARY /usr/local/bin/node-executable

RUN useradd -m -u 1000 -U -s /bin/sh -d /node node && \
mkdir -p /node/.local/share/node && \
Expand Down
3 changes: 3 additions & 0 deletions dip-template/nodes/dip-consumer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ cumulus-relay-chain-interface.workspace = true

[build-dependencies]
substrate-build-script-utils.workspace = true

[features]
default = []
8 changes: 5 additions & 3 deletions dip-template/nodes/dip-consumer/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ use sc_telemetry::TelemetryEndpoints;
use sp_runtime::traits::AccountIdConversion;

use crate::{
chain_spec::{development_config, Extensions},
chain_spec::{development_config, ChainSpec as ConsumerChainSpec, Extensions},
cli::{Cli, RelayChainCli, Subcommand},
service::{new_partial, start_parachain_node},
};

fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
match id {
"dev" => Ok(Box::new(development_config())),
_ => Err("Unrecognized spec ID.".into()),
"dev" | "" => Ok(Box::new(development_config())),
path => Ok(Box::new(ConsumerChainSpec::from_json_file(std::path::PathBuf::from(
path,
))?)),
}
}

Expand Down
3 changes: 3 additions & 0 deletions dip-template/nodes/dip-provider/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,6 @@ cumulus-relay-chain-interface.workspace = true

[build-dependencies]
substrate-build-script-utils.workspace = true

[features]
default = []
8 changes: 5 additions & 3 deletions dip-template/nodes/dip-provider/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,17 @@ use sc_telemetry::TelemetryEndpoints;
use sp_runtime::traits::AccountIdConversion;

use crate::{
chain_spec::{development_config, Extensions},
chain_spec::{development_config, ChainSpec as ProviderChainSpec, Extensions},
cli::{Cli, RelayChainCli, Subcommand},
service::{new_partial, start_parachain_node},
};

fn load_spec(id: &str) -> std::result::Result<Box<dyn ChainSpec>, String> {
match id {
"dev" => Ok(Box::new(development_config())),
_ => Err("Unrecognized spec ID.".into()),
"dev" | "" => Ok(Box::new(development_config())),
path => Ok(Box::new(ProviderChainSpec::from_json_file(std::path::PathBuf::from(
path,
))?)),
}
}

Expand Down

0 comments on commit 66b46be

Please sign in to comment.