Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #41 from primevprotocol/iowar/docker.0
Browse files Browse the repository at this point in the history
fix: multiple docker builder searcher support
  • Loading branch information
iowar authored Oct 6, 2023
2 parents 6cc5c3b + 7f2a7f4 commit af975f7
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,44 @@ echo "Node Type: $NODE_TYPE"
# Define paths
KEY_PATH="/keys"
CONFIG_PATH="/config"
IP=$(ifconfig eth0|grep inet|awk -F" " '{print $2}'|cut -d":" -f2)

# Check whether the private key file based on node type already exists
if [ "$NODE_TYPE" = "bootnode" ]; then
PRIV_KEY_FILE="${KEY_PATH}/bootnode"
CONFIG_FILE="${CONFIG_PATH}/bootnode.yml"
elif [ "$NODE_TYPE" = "builder" ]; then
PRIV_KEY_FILE="${KEY_PATH}/builder"
CONFIG_FILE="${CONFIG_PATH}/builder.yml"
PRIV_KEY_FILE="${KEY_PATH}/builder${IP}"
CONFIG_FILE="${CONFIG_PATH}/builder${IP}.yml"

if [ ! -f "$CONFIG_FILE" ]; then
cd $CONFIG_PATH
cp builder.yml builder${IP}.yml
cd -
fi
else
PRIV_KEY_FILE="${KEY_PATH}/searcher"
CONFIG_FILE="${CONFIG_PATH}/searcher.yml"
PRIV_KEY_FILE="${KEY_PATH}/searcher${IP}"
CONFIG_FILE="${CONFIG_PATH}/searcher${IP}.yml"

if [ ! -f "$CONFIG_FILE" ]; then
cd $CONFIG_PATH
cp searcher.yml searcher${IP}.yml
cd -
fi

fi

# Generate the private key based on node type only if it doesn't exist yet
if [ ! -f "$PRIV_KEY_FILE" ]; then

if [ "$NODE_TYPE" != "bootnode" ]; then
/app/mev-commit create-key ${PRIV_KEY_FILE}
# Update the private key path in the configuration
sed -i "s|priv_key_file:.*|priv_key_file: ${PRIV_KEY_FILE}|" ${CONFIG_FILE}
else
echo "Key file ${PRIV_KEY_FILE} already exists. Skipping key creation."
fi

if [ "$NODE_TYPE" == "bootnode" ] && [ ! -f "$PRIV_KEY_FILE" ];then
/app/mev-commit create-key ${PRIV_KEY_FILE}
# Update the private key path in the configuration
sed -i "s|priv_key_file:.*|priv_key_file: ${PRIV_KEY_FILE}|" ${CONFIG_FILE}
fi

# If this is not the bootnode, update the bootnodes entry with P2P ID
Expand Down

0 comments on commit af975f7

Please sign in to comment.