From f5dff589e921de95604f8fd97980b0f02082bfae Mon Sep 17 00:00:00 2001 From: John Lotoski Date: Fri, 7 Feb 2025 15:02:13 -0600 Subject: [PATCH] imp: align node oci scripts mode and custom mode defaults --- nix/docker/context/bin/run-node | 15 +++++++++++---- nix/docker/default.nix | 30 ++++++++++++++++++++++-------- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/nix/docker/context/bin/run-node b/nix/docker/context/bin/run-node index 85f704a0653..ec38bed745f 100755 --- a/nix/docker/context/bin/run-node +++ b/nix/docker/context/bin/run-node @@ -1,6 +1,4 @@ #!/bin/env bash - -# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail set -eo pipefail echo "Running the cardano node ..." @@ -16,12 +14,16 @@ if [[ -z $CARDANO_TOPOLOGY ]]; then CARDANO_TOPOLOGY="$CARDANO_CONFIG_BASE/mainnet/topology.json" fi +# Breaking change from the historical default of: /opt/cardano/data +# in order to align both the "scripts" and "custom" modes of image operation. if [[ -z $CARDANO_DATABASE_PATH ]]; then - CARDANO_DATABASE_PATH="/opt/cardano/data" + CARDANO_DATABASE_PATH="/opt/cardano/data/db" fi +# Breaking change from the historical default of: /opt/cardano/ipc/socket +# in order to align both the "scripts" and "custom" modes of image operation. if [[ -z $CARDANO_SOCKET_PATH ]]; then - CARDANO_SOCKET_PATH="/opt/cardano/ipc/socket" + CARDANO_SOCKET_PATH="/opt/cardano/ipc/node.socket" fi if [[ -z $CARDANO_LOG_DIR ]]; then @@ -102,7 +104,12 @@ CARDANO_BLOCK_PRODUCER=$CARDANO_BLOCK_PRODUCER CNODE_HOSTNAME="$CARDANO_PUBLIC_IP" CNODE_PORT=$CARDANO_PORT CUSTOM_PEERS="$CARDANO_CUSTOM_PEERS" + +# Breaking change from the historical default of: +# $CARDANO_CONFIG_BASE/mainnet-shelley-genesis.json in order to align +# use of the by network organized configuration files. GENESIS_JSON="$CARDANO_CONFIG_BASE/mainnet/shelley-genesis.json" + TOPOLOGY="$CARDANO_TOPOLOGY" LOG_DIR="$CARDANO_LOG_DIR" EOF diff --git a/nix/docker/default.nix b/nix/docker/default.nix index 2f9452eccd8..c199971c66a 100644 --- a/nix/docker/default.nix +++ b/nix/docker/default.nix @@ -144,17 +144,31 @@ in created = "now"; extraCommands = '' - # These directories serve as defaults when the node docker container uses the `run` arg. - # Alternatively, when the NETWORK environment variable is set the defaults are different. - # TODO: Reduce the confusion on this. - mkdir -p opt/cardano/data - mkdir -p opt/cardano/ipc - mkdir -p opt/cardano/logs + # The "scripts" operation mode of this image, when the NETWORK env var is + # set to a valid network, will use the following default directories + # mounted at /: + mkdir -p data + mkdir -p ipc + + # Similarly, make a root level dir for logs: + mkdir -p logs + + # The "custom" operation mode of this image, when the NETWORK env is + # unset and `run` is provided as an entrypoint arg, will use the + # following default directories. To reduce confusion caused by default + # directory paths varying by mode, symlink these directories to the + # "scripts" mode default directories at the root location. This will + # permit use of volume mounts at the root directory location regardless + # of which mode the image is operating in. + mkdir -p opt/cardano + ln -sv /data opt/cardano/data + ln -sv /ipc opt/cardano/ipc + ln -sv /logs opt/cardano/logs + + # Setup bins mkdir -p usr/local/bin - cp -v ${runNetwork}/bin/* usr/local/bin cp -v ${context}/bin/* usr/local/bin - ln -sv ${cardano-node}/bin/cardano-node usr/local/bin/cardano-node ln -sv ${cardano-cli}/bin/cardano-cli usr/local/bin/cardano-cli