Skip to content
Prev Previous commit
Next Next commit
KP-86: Reduce footprint of final image, add shell scripts for conveni…
…ence use, rename "local-testnet" to "kilt-testnet"
  • Loading branch information
Andreas Pasch committed Dec 4, 2018
commit 7d806d9d183d7f8adfaca84e57dee296f8fffd5e
37 changes: 25 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:xenial
FROM ubuntu:xenial as builder

WORKDIR /substrate
WORKDIR /build

# install tools and dependencies
RUN apt -y update && \
Expand Down Expand Up @@ -48,22 +48,35 @@ ENV CXX g++
ENV LC_ALL=C.UTF-8
ENV LANG=C.UTF-8

COPY . /substrate
COPY . /build

RUN /bin/bash build.sh

RUN cargo build && cargo test

EXPOSE 30333 9933 9944

RUN ls -la .
FROM ubuntu:xenial

# boot node for Alice:
# ./target/debug/node --chain local --key Alice --name "ALICE" --node-key 0000000000000000000000000000000000000000000000000000000000000001 --validator --telemetry-url ws://telemetry-backend.kilt-prototype.tk:1024
# Alice's address: /ip4/0.0.0.0/tcp/30333/p2p/QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN
WORKDIR /runtime
RUN mkdir -p /runtime/target/debug/
COPY --from=builder /build/target/debug/node ./target/debug/node
COPY --from=builder /build/scripts/kilt-node-testnet.sh ./kilt-node-testnet.sh
COPY --from=builder /build/scripts/lookup-master-bootnode-testnet.sh ./lookup-master-bootnode-testnet.sh
COPY --from=builder /build/scripts/kilt-master-bootnode-testnet.sh ./kilt-master-bootnode-testnet.sh

# boot node for Bob:
# ./target/debug/node --chain local --key Bob --name "BOB" --node-key 0000000000000000000000000000000000000000000000000000000000000002 --validator --telemetry-url ws://telemetry-backend.kilt-prototype.tk:1024
# Bobs address: /ip4/0.0.0.0/tcp/30333/p2p/QmXiB3jqqn2rpiKU7k1h7NJYeBg8WNSx9DiTRKz9ti2KSK
RUN chmod a+x *.sh
RUN ls -la .

# expose node ports
EXPOSE 30333 9933 9944

CMD ["./target/debug/node", "--chain", "local", "--key", "Alice", "--name", "\"ALICE\"", "--node-key", "0000000000000000000000000000000000000000000000000000000000000001", "--validator"]
#
# Pass the node start command to the docker run command
#
# To start a master boot node (no initial connection to other nodes):
# ./kilt-master-bootnode-testnet.sh --key Alice --name "ALICE" --node-key 0000000000000000000000000000000000000000000000000000000000000001
#
# To start a node that connects to the master bootnode:
# ./kilt-node-testnet.sh --key Charly --name "CHARLY"
#
CMD ["echo","\"Please provide a startup command.\""]
38 changes: 32 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,43 @@

Substrate node implementation for the KILT prototype

## Running a local node that connects to the KILT prototype test environment in AWS
## Running a local node that connects to the KILT prototype testnet in AWS

There are 2 boot nodes running in the KILT test net:
There is a master boot node running in the KILT testnet:

* bootnode-alice
* bootnode-bob
* bootnode-alice (bootnode-alice.kilt-prototype.tk)

To connect to the Alice node you can use the shell script `connect.sh`:
To connect to the Alice node you can use the shell script `kilt-node-testnet.sh`:

```
connect.sh --key Charly --name "CHARLY"
cd scripts/
kilt-node-testnet.sh --key Charly --name "CHARLY"
```

You can use any of the accounts declared in the chain spec to connect (Alice, Bob, Charly, Dave, Eve, Ferdie).


### Running a node inside a docker container

Make sure to have the `awscli` installed. Otherwise Install it via `brew install awscli` (Mac).
You also need to have your docker daemon system running (on mac, just download the docker application).

Login to Amazon ECR

```
$(aws ecr get-login --no-include-email --region eu-central-1)
```

Pull the latest image from Amazon ECR

```
docker pull 348099934012.dkr.ecr.eu-central-1.amazonaws.com/kilt/prototype-chain:latest
```

Run the image and pass the command to start a node

```
docker run 348099934012.dkr.ecr.eu-central-1.amazonaws.com/kilt/prototype-chain ./kilt-node-testnet.sh --key Charly --name "CHARLY"
```

The node should be connected to the KILT testnet.
25 changes: 0 additions & 25 deletions connect.sh

This file was deleted.

12 changes: 12 additions & 0 deletions scripts/kilt-master-bootnode-testnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

#
# This script starts a kilt master boot node with provided account, name and node-key
#
# Run:
# ./kilt-master-bootnode-testnet.sh --key Alice --name "ALICE" --node-key 0000000000000000000000000000000000000000000000000000000000000001
#

echo "Starting KILT master boot node..."
./../target/debug/node --chain kilt-testnet --validator --telemetry-url ws://telemetry-backend.kilt-prototype.tk:1024 "$@"

27 changes: 27 additions & 0 deletions scripts/kilt-node-testnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

#
# This script starts a kilt node and connects to the master boot node of the KILT testnet.
#
# Run:
# ./kilt-node-testnet.sh --key Charly --name "CHARLY"
#

ALICE_BOOT_NODE_DOMAIN=bootnode-alice.kilt-prototype.tk
ALICE_BOOT_NODE_IP=`dig $ALICE_BOOT_NODE_DOMAIN A +short`
ALICE_BOOT_NODE_KEY=QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN
ALICE_BOOT_NODE_IPFS=/ip4/$ALICE_BOOT_NODE_IP/tcp/30333/p2p/$ALICE_BOOT_NODE_KEY


#BOB_BOOT_NODE_DOMAIN=bootnode-bob.kilt-prototype.tk
#BOB_BOOT_NODE_IP=`dig $BOB_BOOT_NODE_DOMAIN A +short`
#BOB_BOOT_NODE_KEY=QmXiB3jqqn2rpiKU7k1h7NJYeBg8WNSx9DiTRKz9ti2KSK
#BOB_BOOT_NODE_IPFS=/ip4/$BOB_BOOT_NODE_IP/tcp/30333/p2p/$BOB_BOOT_NODE_KEY

MASTER_BOOT_NODE_IPFS=`./lookup-master-bootnode-testnet.sh`


# Connect to master boot node
echo "Master boot node: $MASTER_BOOT_NODE_IPFS..."
./../target/debug/node --chain kilt-testnet --bootnodes $MASTER_BOOT_NODE_IPFS --port 30333 --validator --telemetry-url ws://telemetry-backend.kilt-prototype.tk:1024 "$@"

18 changes: 18 additions & 0 deletions scripts/lookup-master-bootnode-testnet.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

#
# This script performs a lookup for the master boot node and prints out its ipfs address.
#
# Run:
# ./lookup-master-bootnode-testnet.sh
# Prints out the IPFS of the master boot node:
# e.g.:
# /ip4/3.120.148.48/tcp/30333/p2p/QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN
#

ALICE_BOOT_NODE_DOMAIN=bootnode-alice.kilt-prototype.tk
ALICE_BOOT_NODE_IP=`dig $ALICE_BOOT_NODE_DOMAIN A +short`
ALICE_BOOT_NODE_KEY=QmQZ8TjTqeDj3ciwr93EJ95hxfDsb9pEYDizUAbWpigtQN
ALICE_BOOT_NODE_IPFS=/ip4/$ALICE_BOOT_NODE_IP/tcp/30333/p2p/$ALICE_BOOT_NODE_KEY

echo $ALICE_BOOT_NODE_IPFS
10 changes: 5 additions & 5 deletions src/chain_spec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub enum Alternative {
/// Whatever the current runtime is, with just Alice as an auth.
Development,
/// Whatever the current runtime is, with simple Alice/Bob auths.
LocalTestnet,
KiltTestnet,
}

impl Alternative {
Expand All @@ -39,9 +39,9 @@ impl Alternative {
None,
None
),
Alternative::LocalTestnet => ChainSpec::from_genesis(
"Local Testnet",
"local_testnet",
Alternative::KiltTestnet => ChainSpec::from_genesis(
"KILT Testnet",
"kilt_testnet",
|| testnet_genesis(vec![
ed25519::Pair::from_seed(b"Alice ").public().into(),
ed25519::Pair::from_seed(b"Bob ").public().into(),
Expand All @@ -67,7 +67,7 @@ impl Alternative {
pub(crate) fn from(s: &str) -> Option<Self> {
match s {
"dev" => Some(Alternative::Development),
"local" => Some(Alternative::LocalTestnet),
"kilt-testnet" => Some(Alternative::KiltTestnet),
_ => None,
}
}
Expand Down