Skip to content

Commit

Permalink
imp: align node oci scripts mode and custom mode defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
johnalotoski committed Feb 8, 2025
1 parent cd78e51 commit f5dff58
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 12 deletions.
15 changes: 11 additions & 4 deletions nix/docker/context/bin/run-node
Original file line number Diff line number Diff line change
@@ -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 ..."
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
30 changes: 22 additions & 8 deletions nix/docker/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f5dff58

Please sign in to comment.