Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .envrc.qanet
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# overrides for qanet
export MIDNIGHT_NODE_IMAGE="ghcr.io/midnight-ntwrk/midnight-node:0.12.0-rc.3"
export MIDNIGHT_CONTAINER_NAME="midnight-node"

# Well known addresses of network that allow discovery of all other nodes.
export BOOTNODES="/dns/boot-node-01.qanet.dev.midnight.network/tcp/30333/ws/p2p/12D3KooWEyoppNCUx8Yx66oV9fJnriXwCcXwDDUA2kj6vnc6iDEp \
Expand Down
1 change: 1 addition & 0 deletions .envrc.testnet-02
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# overrides for testnet-02
export MIDNIGHT_NODE_IMAGE="midnightnetwork/midnight-node:0.12.0"
export MIDNIGHT_CONTAINER_NAME="midnight-node"

# These are well known addresses of a network that allow you to discover all the other nodes.
export BOOTNODES="/dns/boot-node-01.testnet-02.midnight.network/tcp/30333/ws/p2p/12D3KooWMjUq13USCvQR9Y6yFzYNYgTQBLNAcmc8psAuPx2UUdnB \
Expand Down
2 changes: 1 addition & 1 deletion compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ volumes:

services:
midnight-node-testnet:
container_name: midnight-node
container_name: ${MIDNIGHT_CONTAINER_NAME}
restart: unless-stopped
image: ${MIDNIGHT_NODE_IMAGE}
ports:
Expand Down
6 changes: 3 additions & 3 deletions midnight-node.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/usr/bin/env bash

if [ -z "$MIDNIGHT_NODE_IMAGE" ]; then
echo "Error: Env var MIDNIGHT_NODE_IMAGE is not set or is empty"
if [ -z "$MIDNIGHT_CONTAINER_NAME" ]; then
echo "Error: Env var MIDNIGHT_CONTAINER_NAME is not set or is empty"
echo "Please install direnv and run 'direnv allow' to activate it."
exit 1
fi

docker exec -t midnight /midnight-node "$@"
docker exec -t ${MIDNIGHT_CONTAINER_NAME} /midnight-node "$@"
19 changes: 8 additions & 11 deletions midnight-shell.sh
Original file line number Diff line number Diff line change
@@ -1,30 +1,27 @@
#!/usr/bin/env bash

# Define container name
CONTAINER_NAME="midnight"

# Check if the container already exists
if [ "$(docker ps -a -f name=^${CONTAINER_NAME}$ --format '{{.Names}}' | grep -c -w "${CONTAINER_NAME}")" -eq 0 ]; then
echo "Container '${CONTAINER_NAME}' does not exist. Creating and starting it..."
if [ "$(docker ps -a -f name=^${MIDNIGHT_CONTAINER_NAME}$ --format '{{.Names}}' | grep -c -w "${MIDNIGHT_CONTAINER_NAME}")" -eq 0 ]; then
echo "Container '${MIDNIGHT_CONTAINER_NAME}' does not exist. Creating and starting it..."

# Run the container with the specified configuration
docker run -it \
--name ${CONTAINER_NAME} \
--name ${MIDNIGHT_CONTAINER_NAME} \
-e CFG_PRESET="${CFG_PRESET}" \
-e DB_SYNC_POSTGRES_CONNECTION_STRING="${DB_SYNC_POSTGRES_CONNECTION_STRING}" \
-v ./data:/data \
-v "./envs/${CFG_PRESET}/pc-chain-config.json:/pc-chain-config.json" \
--entrypoint bash \
"${MIDNIGHT_NODE_IMAGE}"
else
echo "Container '${CONTAINER_NAME}' already exists. Opening an interactive shell..."
echo "Container '${MIDNIGHT_CONTAINER_NAME}' already exists. Opening an interactive shell..."

# Check if the container is running, if not, start it
if [ "$(docker ps -f name=^${CONTAINER_NAME}$ --format '{{.Names}}' | grep -c -w "${CONTAINER_NAME}")" -eq 0 ]; then
echo "Starting container '${CONTAINER_NAME}'..."
docker start ${CONTAINER_NAME}
if [ "$(docker ps -f name=^${MIDNIGHT_CONTAINER_NAME}$ --format '{{.Names}}' | grep -c -w "${MIDNIGHT_CONTAINER_NAME}")" -eq 0 ]; then
echo "Starting container '${MIDNIGHT_CONTAINER_NAME}'..."
docker start ${MIDNIGHT_CONTAINER_NAME}
fi

# Open an interactive shell in the container
docker exec -it ${CONTAINER_NAME} /bin/bash
docker exec -it ${MIDNIGHT_CONTAINER_NAME} /bin/bash
fi
2 changes: 1 addition & 1 deletion reset-midnight.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
# This script will reset the midnight node's data back to nothing.
#

docker rm -f midnight
docker rm -f ${MIDNIGHT_CONTAINER_NAME}
rm -R ./data
docker volume rm midnight-node-docker_midnight-data-testnet
8 changes: 4 additions & 4 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,9 @@ fi
#
# Check midnight-node has peers:
#
midnight=$(docker ps --filter "name=midnight")
if [[ "$midnight" != *"midnight"* ]]; then
echo "❌ midnight container not running, please run docker compose -d"
container_status=$(docker ps --filter "name=${MIDNIGHT_CONTAINER_NAME}" --format "{{.Names}}")
if [[ "$container_status" != *"$MIDNIGHT_CONTAINER_NAME"* ]]; then
echo "❌ ${MIDNIGHT_CONTAINER_NAME} container not running, please run: docker compose up -d"
exit 1
fi

Expand All @@ -136,7 +136,7 @@ if [[ "$SHOULD_HAVE_PEERS" == "true" && "$PEERS" -lt 1 ]]; then

echo "$HEALTH"

docker logs midnight 2>&1 | grep "Genesis mismatch"
docker logs ${MIDNIGHT_CONTAINER_NAME} 2>&1 | grep "Genesis mismatch"
echo "For genesis mismatch, check that CFG_PRESET=$CFG_PRESET is aligned with BOOTNODES=$BOOTNODES"
echo "If they're aligned then run ./reset-midnight.sh and restart"
exit 1
Expand Down