From 0013dc726a18d928d83a5e057adf7dcf7cb17029 Mon Sep 17 00:00:00 2001 From: Rhys Bartels-Waller Date: Thu, 16 Jul 2020 16:52:06 +1000 Subject: [PATCH] chore: Updates nixos and Docker image to conform with genesis file changes. BREAKING CHANGE: `--genesis-file` is no longer a CLI argument in the nixos service. The Docker image no longer establishes a pattern of conventional mount location for provided configuration and IPC socket, instead mount it where you wish and pass `--config` and `--socket-path` as the CMD. ``--schema-dir` is set internally. This does not impact the mode of operation when selecting the IOHK-managed configuration via NETWORK env. --- doc/building-running.md | 3 --- nix/docker.nix | 39 +++++++++++---------------- nix/nixos/cardano-db-sync-service.nix | 1 - 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/doc/building-running.md b/doc/building-running.md index 3adaa3c89..08cbe09f7 100644 --- a/doc/building-running.md +++ b/doc/building-running.md @@ -39,7 +39,6 @@ nix-build -A cardano-db-sync -o db-sync-node scripts/postgresql-setup.sh --createdb PGPASSFILE=config/pgpass db-sync-node/bin/cardano-db-sync \ --config config/mainnet-config.yaml \ - --genesis-file ../cardano-node/configuration/mainnet-genesis.json \ --socket-path ../cardano-node/state-node-mainnet/node.socket \ --schema-dir schema/ ``` @@ -61,13 +60,11 @@ and then the two `db-sync` process run as: ``` PGPASSFILE=config/pgpass ./cardano-db-sync-extended-exe \ --config config/mainnet-config.yaml \ - --genesis-file ../cardano-node/mainnet-genesis.json \ --socket-path ../cardano-node/state-node-mainnet/node.socket --schema-dir schema/ ``` and ``` PGPASSFILE=config/pgpass-testnet ./cardano-db-sync-extended-exe \ --config config/testnet-config.yaml \ - --genesis-file ../cardano-node/configuration/mainnet-ci/testnet-genesis.json \ --socket-path ../cardano-node/state-node-testnet/node.socket --schema-dir schema/ ``` diff --git a/nix/docker.nix b/nix/docker.nix index 46c779b2c..5dfb264ec 100644 --- a/nix/docker.nix +++ b/nix/docker.nix @@ -5,33 +5,30 @@ # # docker load -i $(nix-build -A dockerImage --no-out-link) # -# cardano-db-sync and cardano-db-sync-extended are interchangeable in the following: -# -# To launch with provided mainnet or testnet configuration +# To launch with pre-loaded configuration, using the NETWORK env. # # docker run \ # -v $PATH_TO/node-ipc:/node-ipc \ # -v $PATH_TO/pgpass:/configuration/pgpass \ # -e NETWORK=mainnet|testnet \ # -# To launch the extended service: +# Provide an (almost*) complete command otherwise: # -# docker run \ -# -v $PATH_TO/node-ipc:/node-ipc \ -# -v $PATH_TO/pgpass:/configuration/pgpass \ -# -e NETWORK=mainnet|testnet \ -# -e EXTENDED=true +# docker run \ +# -v $PWD/config/mainnet-config:/configuration/configuration.yaml +# -v $PWD/node-ipc:/node-ipc \ +# -v $PWD/config/pgpass:/pgpass \ +# -e PGPASSFILE=/pgpass +# inputoutput/cardano-db-sync run \ +# --config /configuration/configuration.yaml \ +# --socket-path /node-ipc/node.socket \ # -# To launch with custom configuration, mount a dir containing configuration.yaml, genesis.json, -# and pgpass into /configuration -# -# docker run \ -# -v $PATH_TO/node-ipc:/node-ipc \ -# -v $PATH_TO/configuration:/configuration \ -# inputoutput/cardano-db-sync: +# * --schema-dir is set within the script # +# To launch the extended service include -e EXTENDED=true # See the docker-compose.yml for demonstration of using Docker secrets instead of mounting a pgpass # +# ############################################################################ { iohkNix @@ -140,7 +137,7 @@ let export PGPASSFILE=/configuration/pgpass # set up /tmp (override with TMPDIR variable) mkdir -p -m 1777 tmp - if [[ -f /configuration/configuration.yaml ]]; then + if [[ -z "$NETWORK" ]]; then echo "Connecting to network specified in configuration.yaml" if [[ ! -z "''${EXTENDED}" ]] && [[ "''${EXTENDED}" == true ]] then @@ -149,14 +146,10 @@ let DBSYNC=${cardano-db-sync}/bin/cardano-db-sync fi exec $DBSYNC \ - --socket-path /node-ipc/node.socket \ - --genesis-file /configuration/genesis.json \ - --config /configuration/configuration.yaml \ - --schema-dir ${../schema} + --schema-dir ${../schema} $@ ${clusterStatements} else - echo "Please set a NETWORK environment variable to one of: mainnet/testnet" - echo "Or mount a /configuration volume containing: configuration.yaml, genesis.json, pgpass" + echo "Managed configuration for network "$NETWORK" does not exist" fi ''; in dockerTools.buildImage { diff --git a/nix/nixos/cardano-db-sync-service.nix b/nix/nixos/cardano-db-sync-service.nix index 3388fe8fd..3b9fdcaa8 100644 --- a/nix/nixos/cardano-db-sync-service.nix +++ b/nix/nixos/cardano-db-sync-service.nix @@ -112,7 +112,6 @@ in { mkdir -p log-dir exec ${exec} \ --config ${configFile} \ - --genesis-file ${envConfig.genesisFile} \ --socket-path "$CARDANO_NODE_SOCKET_PATH" \ --schema-dir ${../../schema} '';