diff --git a/distance-oracle/README.md b/distance-oracle/README.md index 5a4233827626c53a79da4b6750ec3bb93f6918c3..b812f3d656d2be9967d4a4dcbc234d4c0ad261af 100644 --- a/distance-oracle/README.md +++ b/distance-oracle/README.md @@ -17,4 +17,17 @@ This feature is organized in multiple parts: - **/distance-oracle/** (here): binary executing the distance algorithm - **/primitives/distance/**: primitive types used both by client and runtime - **/client/distance/**: exposes the `create_distance_inherent_data_provider` which provides data to the runtime -- **/pallets/distance/**: distance pallet exposing type, traits, storage/calls/hooks executing in the runtime \ No newline at end of file +- **/pallets/distance/**: distance pallet exposing type, traits, storage/calls/hooks executing in the runtime + +## Usage (with Docker) + +Exemple for GDev: + +> Supposes that you have a Docker host with a `/data/duniter-v2s` folder that is used as a mounted volume for a duniter-v2s validator node to `/var/lib/duniter`. + +```bash +docker run --rm -it --entrypoint docker-distance-entrypoint \ + -v /data/duniter-v2s/chains/gdev/distance/:/distance \ + -e ORACLE_RPC_URL=wss://gdev.cgeek.fr:443 \ + duniter/duniter-v2s-gdev:latest +``` \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index b35823409800547db8b147ecfc01f4ccec707f71..b24d953349ece26fc02f1696921e690da6b756c1 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -84,6 +84,11 @@ LABEL maintainer="Gilles Filippini <gilles.filippini@pini.fr>" LABEL version="0.0.0" LABEL description="Crypto-currency software (based on Substrate framework) to operate Äž1 libre currency" +RUN apt-get update \ + && apt-get install -y --no-install-recommends ca-certificates + +RUN update-ca-certificates + RUN adduser --home /var/lib/duniter duniter # Configuration @@ -96,3 +101,4 @@ USER duniter # Intall COPY --from=build /root/build /usr/local/bin/ COPY docker/docker-entrypoint /usr/local/bin/ +COPY docker/docker-distance-entrypoint /usr/local/bin/ diff --git a/docker/docker-distance-entrypoint b/docker/docker-distance-entrypoint new file mode 100755 index 0000000000000000000000000000000000000000..0fd0dfad8df1ac1f8af7e5b353fc4b8ad29f5a8b --- /dev/null +++ b/docker/docker-distance-entrypoint @@ -0,0 +1,21 @@ +#!/bin/bash + +# Custom startup if a first argument is present and is equal to '--' +# then we just run duniter with the provided arguments (but the '--') +# without applying all the automated configuration below +if [ "$1" = -- ]; then + shift + distance-oracle "$@" +fi + +ORACLE_RESULT_DIR="${ORACLE_RESULT_DIR:-/distance}" +ORACLE_EXECUTION_INTERVAL="${ORACLE_EXECUTION_INTERVAL:-1800}" +ORACLE_MAX_DEPTH="${ORACLE_MAX_DEPTH:-5}" +ORACLE_RPC_URL="${ORACLE_RPC_URL:-ws://127.0.0.1:9944}" +ORACLE_LOG_LEVEL="${ORACLE_LOG_LEVEL:-info}" + +while [ true ]; do + distance-oracle -d "$ORACLE_RESULT_DIR" -D "$ORACLE_MAX_DEPTH" -u "$ORACLE_RPC_URL" -l "$ORACLE_LOG_LEVEL" + echo "Waiting $ORACLE_EXECUTION_INTERVAL seconds before next execution..." + sleep $ORACLE_EXECUTION_INTERVAL +done