Skip to content
Snippets Groups Projects
Commit 79af3260 authored by Gilles Filippini's avatar Gilles Filippini
Browse files

docker: simplify duniter subcommand run

When the first argument of the entrypoint is not an option or is '--'
then bypass the default configuration via environment variables and
directly run duniter with the given parameters (after removing the first
one when it is '--').

The affected scripts and documentation were updated.
parent 9388f18b
No related branches found
No related tags found
No related merge requests found
This commit is part of merge request !135. Comments created here will be created in the context of that merge request.
...@@ -80,3 +80,24 @@ You can pass any other option to duniter using the `command` docker-compose elem ...@@ -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 # https://github.com/paritytech/substrate/issues/12073
- "--wasm-execution=interpreted-i-know-what-i-do" - "--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 ...
```
#!/bin/bash #!/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 () { function boolean () {
echo "$1" | sed -E 's/^(true|yes|1)$/true/i' echo "$1" | sed -E 's/^(true|yes|1)$/true/i'
} }
......
...@@ -21,7 +21,7 @@ docker image that you have chosen. ...@@ -21,7 +21,7 @@ docker image that you have chosen.
Generate a random secret phrase: Generate a random secret phrase:
```bash ```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 phrase: noble stay fury mean poverty delay stadium organ evil east vague can
Secret seed: 0xb39c31fb10c5080721738880c2ea45412cb3df33df022bf8d9a51483b3a9b7a6 Secret seed: 0xb39c31fb10c5080721738880c2ea45412cb3df33df022bf8d9a51483b3a9b7a6
Public key (hex): 0x90a0c2866034db9d05f8193a95fe5af8d5e12ab295a501c17c95cdbeaf226d62 Public key (hex): 0x90a0c2866034db9d05f8193a95fe5af8d5e12ab295a501c17c95cdbeaf226d62
...@@ -35,7 +35,7 @@ Keep this secret phrase **carefully**, it will be used **several** times later. ...@@ -35,7 +35,7 @@ Keep this secret phrase **carefully**, it will be used **several** times later.
Then, generate the session keys: Then, generate the session keys:
```bash ```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 Session Keys: 0x87189d723e1b2826c243bc433c718ac26ba60526932216a09102a254d54462b890a0c2866034db9d05f8193a95fe5af8d5e12ab295a501c17c95cdbeaf226d6290a0c2866034db9d05f8193a95fe5af8d5e12ab295a501c17c95cdbeaf226d6290a0c2866034db9d05f8193a95fe5af8d5e12ab295a501c17c95cdbeaf226d62
``` ```
...@@ -46,7 +46,7 @@ An example of genesis configuration file: `resources/gdev.json` ...@@ -46,7 +46,7 @@ An example of genesis configuration file: `resources/gdev.json`
## 5. Generate raw spec ## 5. Generate raw spec
```docker ```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 ```bash
......
...@@ -31,8 +31,7 @@ mkdir -p $WORK_DIR/duniter-validator/chains/$CURRENCY ...@@ -31,8 +31,7 @@ mkdir -p $WORK_DIR/duniter-validator/chains/$CURRENCY
# Helper to execute a duniter subcommand in docker # Helper to execute a duniter subcommand in docker
function duniter_tmp () { function duniter_tmp () {
docker rm duniter-tmp > /dev/null OUTPUT=$(docker run --rm --name duniter-tmp duniter/duniter-v2s:$DUNITER_IMAGE_TAG "$@")
OUTPUT=$(docker run --name duniter-tmp -it --entrypoint duniter duniter/duniter-v2s:$DUNITER_IMAGE_TAG "$@")
echo "${OUTPUT::-1}" echo "${OUTPUT::-1}"
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment