diff --git a/docker/README.md b/docker/README.md index e93db2e0f64c888041ce7596d67394ff067e74fa..01d093e6beb6fab4a0030d28f2099eb2712226d6 100644 --- a/docker/README.md +++ b/docker/README.md @@ -80,3 +80,24 @@ You can pass any other option to duniter using the `command` docker-compose elem # https://github.com/paritytech/substrate/issues/12073 - "--wasm-execution=interpreted-i-know-what-i-do" ``` + +# Running duniter subcommands + +You can run any duniter subcommand this way: +``` +$ docker run --rm duniter/duniter-v2s:latest <subcommand> ... +``` + +For example to generate a key: +``` +$ docker run --rm duniter/duniter-v2s:latest key generate +``` + +In this case the `DUNITER_*` environment variables are ignored. + +# Running custom duniter options + +To test duniter from the command line without the default configuration detailed in the "Environment variables" section use `--` as the first argument. For example: +``` +$ docker run --rm duniter/duniter-v2s:latest -- --chain gdev ... +``` diff --git a/docker/docker-entrypoint b/docker/docker-entrypoint index 8e751d47be9f2de3bfb4c35ce9094de73988d1ac..769b9b328b29903ada6a32454cfc47aacff974b1 100755 --- a/docker/docker-entrypoint +++ b/docker/docker-entrypoint @@ -1,5 +1,19 @@ #!/bin/bash +# Subcommand or custom startup +# If a first argument is present +# * and is not an option (doesn't start with '-') +# * or is equal to '--' +# then we just run duniter with the provided arguments (but the first '--') +# without applying all the automated configuration below +if [ -n "$1" -a \( "${1:0:1}" != - -o "$1" = -- \) ]; then + if [ "$1" = -- ]; then + shift + fi + exec duniter "$@" +fi + +# Normal startup function boolean () { echo "$1" | sed -E 's/^(true|yes|1)$/true/i' } diff --git a/docs/dev/launch-a-live-network.md b/docs/dev/launch-a-live-network.md index c6392efc6dac34d218d406f87e03ba824ac61616..5ab7230d37028271b9f55fe5b4b143ef0d5eb094 100644 --- a/docs/dev/launch-a-live-network.md +++ b/docs/dev/launch-a-live-network.md @@ -21,7 +21,7 @@ docker image that you have chosen. Generate a random secret phrase: ```bash -$ docker run --rm -it --entrypoint duniter duniter/duniter-v2s:TAG key generate +$ docker run --rm duniter/duniter-v2s:TAG key generate Secret phrase: noble stay fury mean poverty delay stadium organ evil east vague can Secret seed: 0xb39c31fb10c5080721738880c2ea45412cb3df33df022bf8d9a51483b3a9b7a6 Public key (hex): 0x90a0c2866034db9d05f8193a95fe5af8d5e12ab295a501c17c95cdbeaf226d62 @@ -35,7 +35,7 @@ Keep this secret phrase **carefully**, it will be used **several** times later. Then, generate the session keys: ```bash -$ docker run --rm -it --entrypoint duniter duniter/duniter-v2s:TAG key generate-session-keys --chain CURRENCY_local --suri "<your secret phrase>" +$ docker run --rm duniter/duniter-v2s:TAG key generate-session-keys --chain CURRENCY_local --suri "<your secret phrase>" Session Keys: 0x87189d723e1b2826c243bc433c718ac26ba60526932216a09102a254d54462b890a0c2866034db9d05f8193a95fe5af8d5e12ab295a501c17c95cdbeaf226d6290a0c2866034db9d05f8193a95fe5af8d5e12ab295a501c17c95cdbeaf226d6290a0c2866034db9d05f8193a95fe5af8d5e12ab295a501c17c95cdbeaf226d62 ``` @@ -46,7 +46,7 @@ An example of genesis configuration file: `resources/gdev.json` ## 5. Generate raw spec ```docker -docker run -v $HOME/dev/duniter-v2s/resources:/var/lib/duniter/resources -e DUNITER_GENESIS_CONFIG=/var/lib/duniter/resources/gdev.json --rm -it --entrypoint duniter duniter/duniter-v2s:TAG build-spec -lerror --chain=gdev-gl --raw > name-raw.json +docker run -v $HOME/dev/duniter-v2s/resources:/var/lib/duniter/resources -e DUNITER_GENESIS_CONFIG=/var/lib/duniter/resources/gdev.json --rm duniter/duniter-v2s:TAG build-spec -lerror --chain=gdev-gl --raw > name-raw.json ``` ```bash diff --git a/scripts/create-live-network.sh b/scripts/create-live-network.sh index 5e9bd62b8d73bb392d1c3906de0a2db7d62b1700..f1f7471e3488a9078e6f863c58b59c68474b4808 100755 --- a/scripts/create-live-network.sh +++ b/scripts/create-live-network.sh @@ -31,8 +31,7 @@ mkdir -p $WORK_DIR/duniter-validator/chains/$CURRENCY # Helper to execute a duniter subcommand in docker function duniter_tmp () { - docker rm duniter-tmp > /dev/null - OUTPUT=$(docker run --name duniter-tmp -it --entrypoint duniter duniter/duniter-v2s:$DUNITER_IMAGE_TAG "$@") + OUTPUT=$(docker run --rm --name duniter-tmp duniter/duniter-v2s:$DUNITER_IMAGE_TAG "$@") echo "${OUTPUT::-1}" }