From 93d04d329e30d0b3293d591c0c44587f5f74e419 Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 24 Sep 2024 14:26:43 +0100 Subject: [PATCH 01/14] updated launcher --- scripts/launcher | 357 ++++++++++++++++++++++++++++------------------- 1 file changed, 214 insertions(+), 143 deletions(-) diff --git a/scripts/launcher b/scripts/launcher index c0286472e..b3a9b9685 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -40,7 +40,7 @@ case "$OS" in *) echo "Unsupported OS: $OS"; exit 1;; esac -# Couleurs et styles +# Colors and styles GREEN=$(tput setaf 2) YELLOW=$(tput setaf 3) RED=$(tput setaf 1) @@ -50,11 +50,11 @@ BOLD=$(tput bold) UNDERLINE=$(tput smul) BLINK=$(tput blink) -# IcΓ΄nes ASCII pour les liens sociaux +# ASCII Icons for social links GITHUB_ICON="πŸ”— GitHub: " DOCS_ICON="πŸ“„ Documentation: " -# Fonction pour la barre de progression +# Function for progress bar progress_bar() { local duration=${1} already_done() { for ((done=0; done<$elapsed; done++)); do printf "β–‡"; done } @@ -73,22 +73,22 @@ progress_bar() { # ASCII Art ascii_art() { echo -e "${RED} - ____ - / __ \___ ____ _ ____ _______ - / / / / _ \/ __ \| |/_/ / / / ___/ - / /_/ / __/ /_/ /> " INSTALL_DEPS - + if [ "$INSTALL_DEPS" != "yes" ]; then echo -e "\n${RED}Installation aborted.${NC}" exit 1 else echo -e "\n${GREEN}Installing missing dependencies...${NC}" if [ "$OS" == "Linux" ]; then - sudo apt update - for DEP in "${MISSING_DEPS[@]}"; do - if ! sudo apt install -y "$DEP"; then - echo -e "${RED}Failed to install $DEP.${NC}" - STILL_MISSING_DEPS+=("$DEP") - fi - done + sudo apt update + for DEP in "${MISSING_DEPS[@]}"; do + if [ "$DEP" == "docker" ]; then + echo -e "${GREEN}Installing Docker...${NC}" + curl -fsSL https://get.docker.com -o get-docker.sh + sudo sh get-docker.sh + rm get-docker.sh + sudo usermod -aG docker $USER + newgrp docker + else + if ! sudo apt install -y "$DEP"; then + echo -e "${RED}Failed to install $DEP.${NC}" + fi + fi + done elif [ "$OS" == "Mac" ]; then - for DEP in "${MISSING_DEPS[@]}"; do - if ! brew install "$DEP"; then - echo -e "${RED}Failed to install $DEP.${NC}" - STILL_MISSING_DEPS+=("$DEP") - fi - done - fi - fi - - # Re-check dependencies to ensure all are installed - echo -e "\n${GREEN}Verifying installation of dependencies...${NC}" - RECHECK_MISSING_DEPS=() - for DEP in "${MISSING_DEPS[@]}"; do - DEP_CHECK="${DEPENDENCIES[@]#*:}" - if ! check_dependency "$DEP_CHECK"; then - RECHECK_MISSING_DEPS+=("$DEP") + for DEP in "${MISSING_DEPS[@]}"; do + if [ "$DEP" == "docker" ]; then + echo -e "${GREEN}Please install Docker Desktop from https://www.docker.com/products/docker-desktop and run this script again.${NC}" + exit 1 + else + if ! brew install "$DEP"; then + echo -e "${RED}Failed to install $DEP.${NC}" + fi + fi + done fi - done - if [ ${#RECHECK_MISSING_DEPS[@]} -ne 0 ]; then - echo -e "\n${RED}The following dependencies could not be installed:${NC}" - for DEP in "${RECHECK_MISSING_DEPS[@]}"; do - echo -e "${RED}- $DEP${NC}" + # Re-check dependencies to ensure all are installed + echo -e "\n${GREEN}Verifying installation of dependencies...${NC}" + RECHECK_MISSING_DEPS=() + for DEP in "${DEPENDENCIES[@]}"; do + DEP_NAME="${DEP%%:*}" + DEP_CHECK="${DEP##*:}" + if ! check_dependency "$DEP_CHECK"; then + RECHECK_MISSING_DEPS+=("$DEP_NAME") + fi done - exit 1 - else - echo -e "\n${GREEN}All dependencies are successfully installed and verified.${NC}" + + if [ ${#RECHECK_MISSING_DEPS[@]} -ne 0 ]; then + echo -e "\n${RED}The following dependencies could not be installed:${NC}" + for DEP in "${RECHECK_MISSING_DEPS[@]}"; do + echo -e "${RED}- $DEP${NC}" + done + exit 1 + else + echo -e "\n${GREEN}All dependencies are successfully installed and verified.${NC}" + fi fi else echo -e "\n${GREEN}All dependencies are installed.${NC}" fi - -echo -e "\n${GREEN}We will now proceed with the download and installation of the binary from GitHub:${NC}" +echo -e "\n${GREEN}We will now proceed with the download of Madara from GitHub:${NC}" echo -e "${CYAN}${GITHUB_ICON}${UNDERLINE}https://github.com/madara-alliance/madara${NC}" -echo -e "\n${YELLOW}${BOLD}Do you want to proceed? (yes/no)${NC}" -read -p "> " PROCEED +# Ask for installation directory +echo -e "\n${YELLOW}${BOLD}Where would you like to install Madara? (default is current directory)${NC}" +read -p "> " INSTALL_DIR -tput rc -tput ed +# Set default directory if not provided +INSTALL_DIR=${INSTALL_DIR:-$(pwd)} -if [ "$PROCEED" != "yes" ]; then - echo -e "${RED}Operation aborted.${NC}" - exit 1 +# Clone the Madara repository +echo -e "\n${GREEN}Cloning the Madara repository into ${INSTALL_DIR}...${NC}" +if [ -d "${INSTALL_DIR}/madara" ]; then + echo -e "${YELLOW}Madara directory already exists. Updating...${NC}" + cd "${INSTALL_DIR}/madara" && git pull +else + git clone https://github.com/madara-alliance/madara.git "${INSTALL_DIR}/madara" + cd "${INSTALL_DIR}/madara" fi -# Function to check if a command exists -command_exists () { - type "$1" &> /dev/null ; -} - -# Check if curl is installed -if ! command_exists curl ; then - echo -e "${RED}Error: curl is not installed. Please install curl and try again.${NC}" - exit 1 -fi -# Check if rustup is installed -if ! command_exists rustup ; then - echo -e "${YELLOW}Installing rustup...${NC}" - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - source $HOME/.cargo/env -fi +tput rc +tput ed -# Check if cargo is installed -if ! command_exists cargo ; then - echo -e "${RED}Error: cargo is not installed. Please install Rust and try again.${NC}" - exit 1 -fi +# Build the Docker image +echo -e "\n${GREEN}Building the Docker image... (this operation will take a few minutes)${NC}" +# if ! docker build -t madara .; then +# echo -e "${RED}Docker image build failed. Please check the Dockerfile and try again.${NC}" +# exit 1 +# fi -# Install the binary from a given URL -BIN_URL="https://example.com/path/to/your/binary" # Replace with actual URL -BIN_NAME="madara" # Replace with the actual name of the binary +tput rc +tput ed -echo -e "\n${GREEN}Downloading the binary...${NC}" -curl -L $BIN_URL -o /usr/local/bin/$BIN_NAME -chmod +x /usr/local/bin/$BIN_NAME +# Choose the mode +echo -e "\nπŸ•ΉοΈ ${YELLOW}${BOLD}On which mode would you like to run Madara? (Enter a number)${NC}\n" +echo "${YELLOW}1. Full Node${NC}" +echo "${YELLOW}2. Sequencer${NC}" +echo "${YELLOW}3. Devnet${NC}" +while true; do + read -p "> " MODE_CHOICE + case $MODE_CHOICE in + 1) MODE="full"; break ;; + 2) MODE="sequencer"; break ;; + 3) MODE="devnet"; break ;; + *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, or 3.${NC}" ;; + esac +done tput rc tput ed @@ -265,24 +263,79 @@ done tput rc tput ed -# Choose the network -echo -e "\n🌐 ${YELLOW}${BOLD}On which network? (Enter a number)${NC}\n" -echo "${YELLOW}1. Mainnet${NC}" -echo "${YELLOW}2. Testnet${NC}" -echo "${YELLOW}3. Integration${NC}" -while true; do - read -p "> " NETWORK_CHOICE - case $NETWORK_CHOICE in - 1) NETWORK="main"; break ;; - 2) NETWORK="test"; break ;; - 3) NETWORK="integration"; break ;; - *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, or 3.${NC}" ;; - esac -done +# Choose the network based on the mode +if [ "$MODE" == "sequencer" ] || [ "$MODE" == "devnet" ]; then + # For sequencer and devnet modes + echo -e "\n🌐 ${YELLOW}${BOLD}Please choose one of the available presets or provide a custom chain config path: (Enter a number)${NC}\n" + echo "${YELLOW}1. Starknet Mainnet${NC}" + echo "${YELLOW}2. Starknet Testnet${NC}" + echo "${YELLOW}3. Test${NC}" + echo "${YELLOW}4. Custom Chain config${NC}" + while true; do + read -p "> " NETWORK_CHOICE + case $NETWORK_CHOICE in + 1) PRESET="starknet_mainnet"; break ;; + 2) PRESET="starknet_testnet"; break ;; + 3) PRESET="test"; break ;; + 4) + echo -e "\n${YELLOW}Please provide the path to your custom chain config:${NC}" + read -p "> " CUSTOM_CHAIN_CONFIG + if [ -f "$CUSTOM_CHAIN_CONFIG" ]; then + PRESET="$CUSTOM_CHAIN_CONFIG" + break + else + echo -e "${RED}File not found. Please provide a valid path.${NC}" + fi + ;; + *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}" ;; + esac + done +else + # For full node mode + echo -e "\n🌐 ${YELLOW}${BOLD}Please choose a Network or provide a custom Chain config path: (Enter a number)${NC}\n" + echo "${YELLOW}1. Starknet Mainnet${NC}" + echo "${YELLOW}2. Starknet Testnet${NC}" + echo "${YELLOW}3. Starknet Integration${NC}" + echo "${YELLOW}4. Custom Chain config${NC}" + while true; do + read -p "> " NETWORK_CHOICE + case $NETWORK_CHOICE in + 1) NETWORK="main"; break ;; + 2) NETWORK="test"; break ;; + 3) NETWORK="integration"; break ;; + 4) + echo -e "\n${YELLOW}Please provide the path to your custom chain config or preset:${NC}" + read -p "> " CUSTOM_CHAIN_CONFIG + if [ -f "$CUSTOM_CHAIN_CONFIG" ]; then + NETWORK="$CUSTOM_CHAIN_CONFIG" + break + else + echo -e "${RED}File not found. Please provide a valid path.${NC}" + fi + ;; + *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}" ;; + esac + done +fi tput rc tput ed +# Set the chain config or network option +if [ "$MODE" == "sequencer" ] || [ "$MODE" == "devnet" ]; then + # Use --chain-config with PRESET + CHAIN_CONFIG_OPT="--chain-config=\"${PRESET}\"" +else + # For full node mode + if [ "$NETWORK_CHOICE" -eq 4 ]; then + # Custom chain config + CHAIN_CONFIG_OPT="--chain-config=\"${NETWORK}\"" + else + # Use --network + CHAIN_CONFIG_OPT="--network=\"${NETWORK}\"" + fi +fi + # Ask for the database path echo -e "\nπŸ’Ύ ${YELLOW}${BOLD}Where would you like to store your database? (default: /tmp/madara)${NC}" read -p "> " BASE_PATH @@ -291,6 +344,11 @@ BASE_PATH=${BASE_PATH:-/tmp/madara} tput rc tput ed +# Create the base path directory if it doesn't exist +if [ ! -d "$BASE_PATH" ]; then + mkdir -p "$BASE_PATH" +fi + # Ask for RPC access while true; do echo -e "\nπŸ”Œ ${YELLOW}${BOLD}Do you want to enable RPC access? (yes/no) ${NC}" @@ -306,12 +364,14 @@ tput ed if [ "$RPC_ACCESS" == "yes" ]; then RPC_OPTS="--rpc-cors '*' --rpc-external" - echo -e "\nπŸšͺ ${YELLOW}${BOLD}On which port do you want RPC access? (default: 9933)${NC}" + echo -e "\nπŸšͺ ${YELLOW}${BOLD}On which port do you want RPC access? (default: 9944)${NC}" read -p "> " RPC_PORT - RPC_PORT=${RPC_PORT:-9933} + RPC_PORT=${RPC_PORT:-9944} RPC_OPTS="$RPC_OPTS --rpc-port $RPC_PORT" + PORT_MAPPING="-p $RPC_PORT:$RPC_PORT" else RPC_OPTS="" + PORT_MAPPING="" fi tput rc @@ -319,7 +379,7 @@ tput ed # Ask for the L1 endpoint URL while true; do - echo -e "\nπŸ”— ${YELLOW}${BOLD}Enter the URL of the L1 endpoint:${NC}" + echo -e "\nπŸ”— ${YELLOW}${BOLD}Provide an L1 RPC endpoint (URL format):${NC}" read -p "> " L1_ENDPOINT if [[ $L1_ENDPOINT =~ ^https?:// ]]; then break @@ -331,34 +391,45 @@ done tput rc tput ed -# Synchronize via snapshot or genesis -echo -e "\nπŸ”„ ${YELLOW}${BOLD}Which sync mode would you like? (Enter a number)${NC}\n" -echo "${YELLOW}1. Snap sync (fast)${NC}" -echo "${YELLOW}2. Full sync (safe)${NC}" -while true; do - read -p "> " SYNC_CHOICE - case $SYNC_CHOICE in - 1) SYNC_OPT="--snap"; break ;; - 2) SYNC_OPT=""; break ;; - *) echo -e "${YELLOW}Invalid choice, please enter 1 or 2.${NC}" ;; - esac -done - -tput rc -tput ed - -# Build the final command -COMMAND="/usr/local/bin/$BIN_NAME run --name $NODE_NAME --network=$NETWORK --base-path=$BASE_PATH $RPC_OPTS --l1-endpoint $L1_ENDPOINT $SYNC_OPT" - -echo -e "\nπŸ”„ ${YELLOW}${BOLD}The following command will be executed:${NC}\n" -echo -e "${CYAN}$COMMAND${NC}" +# # Synchronize via snapshot or genesis +# echo -e "\nπŸ”„ ${YELLOW}${BOLD}Which sync mode would you like? (Enter a number)${NC}\n" +# echo "${YELLOW}1. Snap sync (fast)${NC}" +# echo "${YELLOW}2. Full sync (safe)${NC}" +# while true; do +# read -p "> " SYNC_CHOICE +# case $SYNC_CHOICE in +# 1) SYNC_OPT="--snap"; break ;; +# 2) SYNC_OPT=""; break ;; +# *) echo -e "${YELLOW}Invalid choice, please enter 1 or 2.${NC}" ;; +# esac +# done + +# tput rc +# tput ed + +# Build the final Docker run command +DOCKER_COMMAND="docker run -d --name madara-node \ + -v ${BASE_PATH}:/data \ + ${PORT_MAPPING} \ + madara \ + run --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\" ${SYNC_OPT}" + +echo -e "\nπŸ”„ ${YELLOW}${BOLD}The following Docker command will be executed:${NC}\n" +echo -e "${CYAN}$DOCKER_COMMAND${NC}" # Confirm before executing echo -e "\n${YELLOW}${BOLD}Do you want to proceed? (yes/no)${NC}\n" read -p "> " CONFIRM if [ "$CONFIRM" == "yes" ]; then - echo -e "\n${GREEN}Starting the node...${NC}" - eval $COMMAND + echo -e "\n${GREEN}Starting the Madara node via Docker...${NC}" + # Stop and remove any existing container with the same name + if docker ps -a --format '{{.Names}}' | grep -Eq "^madara-node\$"; then + echo -e "\n${YELLOW}A container named 'madara-node' already exists. Stopping and removing it...${NC}" + docker stop madara-node + docker rm madara-node + fi + eval $DOCKER_COMMAND + echo -e "\n${GREEN}Madara node is now running in Docker container 'madara-node'.${NC}" else echo -e "${RED}Command execution aborted.${NC}" fi From fbc246cf626cf41aba4c25a6d6e9b9d3873ca79f Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 24 Sep 2024 14:51:03 +0100 Subject: [PATCH 02/14] fixed more stuff --- scripts/launcher | 55 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 13 deletions(-) diff --git a/scripts/launcher b/scripts/launcher index b3a9b9685..83f5610dd 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -207,7 +207,7 @@ read -p "> " INSTALL_DIR # Set default directory if not provided INSTALL_DIR=${INSTALL_DIR:-$(pwd)} -# Clone the Madara repository +# Clone the Madara repository (this step should be removed when we have images available remotly) echo -e "\n${GREEN}Cloning the Madara repository into ${INSTALL_DIR}...${NC}" if [ -d "${INSTALL_DIR}/madara" ]; then echo -e "${YELLOW}Madara directory already exists. Updating...${NC}" @@ -231,17 +231,19 @@ echo -e "\n${GREEN}Building the Docker image... (this operation will take a few tput rc tput ed +echo -e "\n${GREEN}Madara has been correctly installed here: ${BOLD}${INSTALL_DIR}${NC}${GREEN}.${NC}" + # Choose the mode -echo -e "\nπŸ•ΉοΈ ${YELLOW}${BOLD}On which mode would you like to run Madara? (Enter a number)${NC}\n" +echo -e "\nπŸ•ΉοΈ ${YELLOW}${BOLD} On which mode would you like to run Madara? (Enter a number)${NC}\n" echo "${YELLOW}1. Full Node${NC}" echo "${YELLOW}2. Sequencer${NC}" echo "${YELLOW}3. Devnet${NC}" while true; do read -p "> " MODE_CHOICE case $MODE_CHOICE in - 1) MODE="full"; break ;; - 2) MODE="sequencer"; break ;; - 3) MODE="devnet"; break ;; + 1) MODE="Full"; break ;; + 2) MODE="Sequencer"; break ;; + 3) MODE="Devnet"; break ;; *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, or 3.${NC}" ;; esac done @@ -249,6 +251,8 @@ done tput rc tput ed +echo -e "\n${GREEN}Madara will run in ${BOLD}${MODE}${NC}${GREEN} mode.${NC}" + # Ask for the node name while true; do echo -e "\n${YELLOW}${BOLD}πŸ‘€ What name would you like to give this node?${NC}" @@ -263,6 +267,8 @@ done tput rc tput ed +echo -e "\n${GREEN}Your node has been correctly named: ${BOLD}${NODE_NAME}${NC}${GREEN}.${NC}" + # Choose the network based on the mode if [ "$MODE" == "sequencer" ] || [ "$MODE" == "devnet" ]; then # For sequencer and devnet modes @@ -304,14 +310,35 @@ else 2) NETWORK="test"; break ;; 3) NETWORK="integration"; break ;; 4) - echo -e "\n${YELLOW}Please provide the path to your custom chain config or preset:${NC}" - read -p "> " CUSTOM_CHAIN_CONFIG - if [ -f "$CUSTOM_CHAIN_CONFIG" ]; then - NETWORK="$CUSTOM_CHAIN_CONFIG" - break - else - echo -e "${RED}File not found. Please provide a valid path.${NC}" - fi + tput rc + tput ed + + echo -e "\n${GREEN}You have choosed to run your node under a custom Chain config.${NC}" + + echo -e "\n${YELLOW}${BOLD}🌐 Please choose one of the available presets or provide a custom chain config path: (Enter a number)${NC}\n" + echo "${YELLOW}1. Starknet Mainnet${NC}" + echo "${YELLOW}2. Starknet Testnet${NC}" + echo "${YELLOW}3. Test${NC}" + echo "${YELLOW}4. Custom Chain config${NC}" + while true; do + read -p "> " NETWORK_CHOICE + case $NETWORK_CHOICE in + 1) PRESET="starknet_mainnet"; break ;; + 2) PRESET="starknet_testnet"; break ;; + 3) PRESET="test"; break ;; + 4) + echo -e "\n${YELLOW}Please provide the path to your custom chain config:${NC}" + read -p "> " CUSTOM_CHAIN_CONFIG + if [ -f "$CUSTOM_CHAIN_CONFIG" ]; then + PRESET="$CUSTOM_CHAIN_CONFIG" + break + else + echo -e "${RED}File not found. Please provide a valid path.${NC}" + fi + ;; + *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}" ;; + esac + done ;; *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}" ;; esac @@ -321,6 +348,8 @@ fi tput rc tput ed +echo -e "\n${GREEN}You have choosed to run your node under: ${NETWORK}.${NC}" + # Set the chain config or network option if [ "$MODE" == "sequencer" ] || [ "$MODE" == "devnet" ]; then # Use --chain-config with PRESET From b84ee44101fc5d31b659b01560d321e3ba46b705 Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 24 Sep 2024 15:53:45 +0100 Subject: [PATCH 03/14] added port security --- scripts/launcher | 203 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 137 insertions(+), 66 deletions(-) diff --git a/scripts/launcher b/scripts/launcher index 83f5610dd..4acb12f4f 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -88,7 +88,7 @@ ascii_art echo -e "${GREEN}${BOLD}Welcome to the Madara Docker Launcher!${NC}" echo -e "${GREEN}This script allows you to easily launch a Madara instance using Docker with your desired parameters.${NC}" echo -e "${GREEN}For more information, please refer to our documentation:${NC}" -echo -e "${CYAN}${DOCS_ICON}${UNDERLINE}https://madara.io${NC}" +echo -e "${CYAN}${DOCS_ICON}${UNDERLINE}https://madara.build${NC}" # Save cursor position tput sc @@ -106,10 +106,9 @@ if [ "$PROCEED" != "yes" ]; then exit 1 fi -# Define dependencies and their check commands +# Define dependencies and their check commands (excluding Docker) DEPENDENCIES=( "curl:command -v curl" - "docker:command -v docker" "git:command -v git" ) @@ -118,6 +117,24 @@ check_dependency() { eval "$1" >/dev/null 2>&1 } +# Function to check if Docker is installed +check_docker_installed() { + if ! command -v docker >/dev/null 2>&1; then + return 1 + else + return 0 + fi +} + +# Function to check if Docker daemon is running +check_docker_running() { + if ! docker info >/dev/null 2>&1; then + return 1 + else + return 0 + fi +} + # Check dependencies MISSING_DEPS=() for DEP in "${DEPENDENCIES[@]}"; do @@ -128,12 +145,25 @@ for DEP in "${DEPENDENCIES[@]}"; do fi done +# Check for Docker +DOCKER_MISSING=false +DOCKER_NOT_RUNNING=false + +if ! check_docker_installed; then + DOCKER_MISSING=true +elif ! check_docker_running; then + DOCKER_NOT_RUNNING=true +fi + # Report missing dependencies -if [ ${#MISSING_DEPS[@]} -ne 0 ]; then - echo -e "${YELLOW}The following dependencies are missing:${NC}" +if [ ${#MISSING_DEPS[@]} -ne 0 ] || [ "$DOCKER_MISSING" = true ]; then + echo -e "${YELLOW}\nThe following dependencies are missing or not running:${NC}" for DEP in "${MISSING_DEPS[@]}"; do echo -e "${YELLOW}- $DEP${NC}" done + if [ "$DOCKER_MISSING" = true ]; then + echo -e "${YELLOW}- Docker${NC}" + fi echo -e "\n${YELLOW}${BOLD}Do you want to install the missing dependencies? (yes/no)${NC}" read -p "> " INSTALL_DEPS @@ -146,55 +176,94 @@ if [ ${#MISSING_DEPS[@]} -ne 0 ]; then if [ "$OS" == "Linux" ]; then sudo apt update for DEP in "${MISSING_DEPS[@]}"; do - if [ "$DEP" == "docker" ]; then - echo -e "${GREEN}Installing Docker...${NC}" - curl -fsSL https://get.docker.com -o get-docker.sh - sudo sh get-docker.sh - rm get-docker.sh - sudo usermod -aG docker $USER - newgrp docker - else - if ! sudo apt install -y "$DEP"; then - echo -e "${RED}Failed to install $DEP.${NC}" - fi + if ! sudo apt install -y "$DEP"; then + echo -e "${RED}Failed to install $DEP.${NC}" fi done + if [ "$DOCKER_MISSING" = true ]; then + echo -e "${GREEN}Installing Docker...${NC}" + curl -fsSL https://get.docker.com -o get-docker.sh + sudo sh get-docker.sh + rm get-docker.sh + sudo usermod -aG docker $USER + newgrp docker + sudo systemctl start docker + fi elif [ "$OS" == "Mac" ]; then for DEP in "${MISSING_DEPS[@]}"; do - if [ "$DEP" == "docker" ]; then - echo -e "${GREEN}Please install Docker Desktop from https://www.docker.com/products/docker-desktop and run this script again.${NC}" - exit 1 - else - if ! brew install "$DEP"; then - echo -e "${RED}Failed to install $DEP.${NC}" - fi + if ! brew install "$DEP"; then + echo -e "${RED}Failed to install $DEP.${NC}" fi done - fi - - # Re-check dependencies to ensure all are installed - echo -e "\n${GREEN}Verifying installation of dependencies...${NC}" - RECHECK_MISSING_DEPS=() - for DEP in "${DEPENDENCIES[@]}"; do - DEP_NAME="${DEP%%:*}" - DEP_CHECK="${DEP##*:}" - if ! check_dependency "$DEP_CHECK"; then - RECHECK_MISSING_DEPS+=("$DEP_NAME") + if [ "$DOCKER_MISSING" = true ]; then + echo -e "${GREEN}Installing Docker via Homebrew...${NC}" + if ! brew install --cask docker; then + echo -e "${RED}Failed to install Docker.${NC}" + else + echo -e "${GREEN}Docker installed.\nTrying to open /Applications/Docker.app to start the Docker daemon (you may need to do this step yourself if not located under /Applications/Docker.app).${NC}" + open /Applications/Docker.app + # Wait for Docker daemon to start + echo -e "${GREEN}Waiting for Docker daemon to start...${NC}" + while ! docker info >/dev/null 2>&1; do + sleep 1 + done + echo -e "${GREEN}Docker daemon is running.${NC}" + fi fi - done + fi + fi +fi - if [ ${#RECHECK_MISSING_DEPS[@]} -ne 0 ]; then - echo -e "\n${RED}The following dependencies could not be installed:${NC}" - for DEP in "${RECHECK_MISSING_DEPS[@]}"; do - echo -e "${RED}- $DEP${NC}" - done +# Check if Docker daemon is running +if [ "$DOCKER_NOT_RUNNING" = true ]; then + echo -e "\n${YELLOW}Docker is installed but not running.${NC}" + if [ "$OS" == "Linux" ]; then + echo -e "${GREEN}Starting Docker daemon...${NC}" + sudo systemctl start docker + if ! sudo systemctl is-active --quiet docker; then + echo -e "${RED}Failed to start Docker daemon.${NC}" exit 1 else - echo -e "\n${GREEN}All dependencies are successfully installed and verified.${NC}" + echo -e "${GREEN}Docker daemon is running.${NC}" fi + elif [ "$OS" == "Mac" ]; then + echo -e "${GREEN}Docker installed.\nTrying to open /Applications/Docker.app to start the Docker daemon (you may need to do this step yourself if not located under /Applications/Docker.app).${NC}" + open /Applications/Docker.app + # Wait for Docker daemon to start + echo -e "${GREEN}Waiting for Docker daemon to start...${NC}" + while ! docker info >/dev/null 2>&1; do + sleep 1 + done + echo -e "${GREEN}Docker daemon is running.${NC}" fi +fi + +# Re-check dependencies to ensure all are installed and running +echo -e "\n${GREEN}Verifying installation of dependencies...${NC}" +RECHECK_MISSING_DEPS=() +for DEP in "${DEPENDENCIES[@]}"; do + DEP_NAME="${DEP%%:*}" + DEP_CHECK="${DEP##*:}" + if ! check_dependency "$DEP_CHECK"; then + RECHECK_MISSING_DEPS+=("$DEP_NAME") + fi +done + +# Re-check Docker +if ! check_docker_installed; then + RECHECK_MISSING_DEPS+=("Docker") +elif ! check_docker_running; then + RECHECK_MISSING_DEPS+=("Docker daemon not running") +fi + +if [ ${#RECHECK_MISSING_DEPS[@]} -ne 0 ]; then + echo -e "\n${RED}The following dependencies could not be installed or are not running:${NC}" + for DEP in "${RECHECK_MISSING_DEPS[@]}"; do + echo -e "${RED}- $DEP${NC}" + done + exit 1 else - echo -e "\n${GREEN}All dependencies are installed.${NC}" + echo -e "\n${GREEN}All dependencies are successfully installed and verified.${NC}" fi echo -e "\n${GREEN}We will now proceed with the download of Madara from GitHub:${NC}" @@ -207,7 +276,7 @@ read -p "> " INSTALL_DIR # Set default directory if not provided INSTALL_DIR=${INSTALL_DIR:-$(pwd)} -# Clone the Madara repository (this step should be removed when we have images available remotly) +# Clone the Madara repository (this step should be removed when we have images available remotely) echo -e "\n${GREEN}Cloning the Madara repository into ${INSTALL_DIR}...${NC}" if [ -d "${INSTALL_DIR}/madara" ]; then echo -e "${YELLOW}Madara directory already exists. Updating...${NC}" @@ -217,7 +286,6 @@ else cd "${INSTALL_DIR}/madara" fi - tput rc tput ed @@ -270,7 +338,7 @@ tput ed echo -e "\n${GREEN}Your node has been correctly named: ${BOLD}${NODE_NAME}${NC}${GREEN}.${NC}" # Choose the network based on the mode -if [ "$MODE" == "sequencer" ] || [ "$MODE" == "devnet" ]; then +if [ "$MODE" == "Sequencer" ] || [ "$MODE" == "Devnet" ]; then # For sequencer and devnet modes echo -e "\n🌐 ${YELLOW}${BOLD}Please choose one of the available presets or provide a custom chain config path: (Enter a number)${NC}\n" echo "${YELLOW}1. Starknet Mainnet${NC}" @@ -313,7 +381,7 @@ else tput rc tput ed - echo -e "\n${GREEN}You have choosed to run your node under a custom Chain config.${NC}" + echo -e "\n${GREEN}You have chosen to run your node under a custom Chain config.${NC}" echo -e "\n${YELLOW}${BOLD}🌐 Please choose one of the available presets or provide a custom chain config path: (Enter a number)${NC}\n" echo "${YELLOW}1. Starknet Mainnet${NC}" @@ -348,10 +416,10 @@ fi tput rc tput ed -echo -e "\n${GREEN}You have choosed to run your node under: ${NETWORK}.${NC}" +echo -e "\n${GREEN}You have chosen to run your node under: ${NETWORK}.${NC}" # Set the chain config or network option -if [ "$MODE" == "sequencer" ] || [ "$MODE" == "devnet" ]; then +if [ "$MODE" == "Sequencer" ] || [ "$MODE" == "Devnet" ]; then # Use --chain-config with PRESET CHAIN_CONFIG_OPT="--chain-config=\"${PRESET}\"" else @@ -394,8 +462,27 @@ tput ed if [ "$RPC_ACCESS" == "yes" ]; then RPC_OPTS="--rpc-cors '*' --rpc-external" echo -e "\nπŸšͺ ${YELLOW}${BOLD}On which port do you want RPC access? (default: 9944)${NC}" - read -p "> " RPC_PORT - RPC_PORT=${RPC_PORT:-9944} + + while true; do + read -p "> " RPC_PORT + RPC_PORT=${RPC_PORT:-9944} + + # Check if the port is a valid number between 1 and 65535 + if ! [[ "$RPC_PORT" =~ ^[0-9]+$ ]] || [ "$RPC_PORT" -lt 1 ] || [ "$RPC_PORT" -gt 65535 ]; then + echo -e "${RED}⚠️ Invalid port number. Please enter a valid port between 1 and 65535.${NC}" + continue + fi + + # Check if the port is already in use + if lsof -i :"$RPC_PORT" &>/dev/null; then + echo -e "${RED}⚠️ Port $RPC_PORT is already in use. Please choose another port.${NC}" + continue + fi + + # If everything is okay, break the loop + break + done + RPC_OPTS="$RPC_OPTS --rpc-port $RPC_PORT" PORT_MAPPING="-p $RPC_PORT:$RPC_PORT" else @@ -420,28 +507,12 @@ done tput rc tput ed -# # Synchronize via snapshot or genesis -# echo -e "\nπŸ”„ ${YELLOW}${BOLD}Which sync mode would you like? (Enter a number)${NC}\n" -# echo "${YELLOW}1. Snap sync (fast)${NC}" -# echo "${YELLOW}2. Full sync (safe)${NC}" -# while true; do -# read -p "> " SYNC_CHOICE -# case $SYNC_CHOICE in -# 1) SYNC_OPT="--snap"; break ;; -# 2) SYNC_OPT=""; break ;; -# *) echo -e "${YELLOW}Invalid choice, please enter 1 or 2.${NC}" ;; -# esac -# done - -# tput rc -# tput ed - # Build the final Docker run command DOCKER_COMMAND="docker run -d --name madara-node \ -v ${BASE_PATH}:/data \ ${PORT_MAPPING} \ madara \ - run --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\" ${SYNC_OPT}" + run --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\"" echo -e "\nπŸ”„ ${YELLOW}${BOLD}The following Docker command will be executed:${NC}\n" echo -e "${CYAN}$DOCKER_COMMAND${NC}" From 9fa90bc6268938ecf5fbdcb7c00df3940de14d8d Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 24 Sep 2024 17:05:10 +0100 Subject: [PATCH 04/14] small fix until docker image --- Dockerfile | 21 ++++++++++++++++++++- scripts/launcher | 6 +++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index b7f53af18..84ad97a6a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,25 @@ WORKDIR /usr/src/madara/ # Copy the source code into the container COPY Cargo.toml Cargo.lock ./ COPY crates crates +COPY cairo cairo +COPY cairo_0 cairo_0 + + +# Installing scarb, new since devnet integration +# Installation steps are taken from the scarb build script +# https://github.com/software-mansion/scarb/blob/main/install.sh +ENV SCARB_VERSION="v2.8.2" +ENV SHELL /bin/bash +RUN curl --proto '=https' --tlsv1.2 -sSf https://docs.swmansion.com/scarb/install.sh | sh -s -- ${SCARB_VERSION} +ENV PATH="/root/.local/bin:${PATH}" +RUN scarb --version + +# Install runtime dependencies +RUN apt-get -y update && \ + apt-get install -y openssl ca-certificates busybox && \ + apt-get autoremove -y; \ + apt-get clean; \ + rm -rf /var/lib/apt/lists/* # Build the application in release mode RUN cargo build --release @@ -35,4 +54,4 @@ WORKDIR /usr/local/bin COPY --from=builder /usr/src/madara/target/release/madara . # Set the entrypoint -CMD ["./madara"] \ No newline at end of file +ENTRYPOINT ["./madara"] \ No newline at end of file diff --git a/scripts/launcher b/scripts/launcher index 4acb12f4f..6edc6ea25 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -50,7 +50,7 @@ BOLD=$(tput bold) UNDERLINE=$(tput smul) BLINK=$(tput blink) -# ASCII Icons for social links +# Icons for social links GITHUB_ICON="πŸ”— GitHub: " DOCS_ICON="πŸ“„ Documentation: " @@ -85,10 +85,10 @@ echo -e "${RED} # Welcome message clear ascii_art -echo -e "${GREEN}${BOLD}Welcome to the Madara Docker Launcher!${NC}" +echo -e "${GREEN}${BOLD}Welcome to the Madara Launcher!${NC}" echo -e "${GREEN}This script allows you to easily launch a Madara instance using Docker with your desired parameters.${NC}" echo -e "${GREEN}For more information, please refer to our documentation:${NC}" -echo -e "${CYAN}${DOCS_ICON}${UNDERLINE}https://madara.build${NC}" +echo -e "${CYAN}${DOCS_ICON}${UNDERLINE}https://docs.madara.build${NC}" # Save cursor position tput sc From 9083b7ce98e4a3576667cff764c897a8cd60eadc Mon Sep 17 00:00:00 2001 From: antiyro Date: Mon, 30 Sep 2024 14:26:23 +0100 Subject: [PATCH 05/14] fixed dockerfile --- Dockerfile | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/Dockerfile b/Dockerfile index 1a2ba9ab2..d75185f7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,18 +17,21 @@ COPY crates crates COPY cairo cairo COPY cairo_0 cairo_0 -# Installing scarb, new since devnet integration -# Installation steps are taken from the scarb build script -# https://github.com/software-mansion/scarb/blob/main/install.sh -ENV SCARB_VERSION="v2.8.2" -ENV SCARB_REPO="https://github.com/software-mansion/scarb/releases/download" -ENV PLATFORM="x86_64-unknown-linux-gnu" -ENV SCARB_TARGET="/usr/src/scarb.tar.gz" - -RUN curl -fLS -o $SCARB_TARGET \ - $SCARB_REPO/$SCARB_VERSION/scarb-$SCARB_VERSION-$PLATFORM.tar.gz && \ - tar -xz -C /usr/src/ --strip-components=1 -f $SCARB_TARGET && \ - mv /usr/src/bin/scarb /bin +# Installing Scarb +# Dynamically detect the architecture +ARG SCARB_VERSION="v2.8.2" +ARG SCARB_REPO="https://github.com/software-mansion/scarb/releases/download" +RUN ARCH=$(uname -m); \ + if [ "$ARCH" = "x86_64" ]; then \ + PLATFORM="x86_64-unknown-linux-gnu"; \ + elif [ "$ARCH" = "aarch64" ] || [ "$ARCH" = "arm64" ]; then \ + PLATFORM="aarch64-unknown-linux-gnu"; \ + else \ + echo "Unsupported architecture: $ARCH"; exit 1; \ + fi && \ + curl -fLS -o /usr/src/scarb.tar.gz \ + $SCARB_REPO/$SCARB_VERSION/scarb-$SCARB_VERSION-$PLATFORM.tar.gz && \ + tar -xz -C /usr/local --strip-components=1 -f /usr/src/scarb.tar.gz # Build the application in release mode RUN cargo build --release @@ -49,7 +52,7 @@ WORKDIR /usr/local/bin # Copy the compiled binary from the builder stage COPY --from=builder /usr/src/madara/target/release/madara . -# chain presets to be monted at startup +# Chain presets to be mounted at startup VOLUME crates/primitives/chain_config/presets VOLUME crates/primitives/chain_config/resources From 3f86de7281835da880d4b849ad469ceb980bb2cc Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 11:09:38 +0100 Subject: [PATCH 06/14] added release and docker build workflows --- scripts/launcher | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/scripts/launcher b/scripts/launcher index 6edc6ea25..a8d849117 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -283,6 +283,7 @@ if [ -d "${INSTALL_DIR}/madara" ]; then cd "${INSTALL_DIR}/madara" && git pull else git clone https://github.com/madara-alliance/madara.git "${INSTALL_DIR}/madara" + git checkout fix/launcher-script cd "${INSTALL_DIR}/madara" fi @@ -309,9 +310,9 @@ echo "${YELLOW}3. Devnet${NC}" while true; do read -p "> " MODE_CHOICE case $MODE_CHOICE in - 1) MODE="Full"; break ;; - 2) MODE="Sequencer"; break ;; - 3) MODE="Devnet"; break ;; + 1) MODE="full"; break ;; + 2) MODE="sequencer"; break ;; + 3) MODE="devnet"; break ;; *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, or 3.${NC}" ;; esac done @@ -512,7 +513,7 @@ DOCKER_COMMAND="docker run -d --name madara-node \ -v ${BASE_PATH}:/data \ ${PORT_MAPPING} \ madara \ - run --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\"" + run --${MODE} --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\"" echo -e "\nπŸ”„ ${YELLOW}${BOLD}The following Docker command will be executed:${NC}\n" echo -e "${CYAN}$DOCKER_COMMAND${NC}" From 7381ac9af420d244213fab64d1d5d340b34f1f82 Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 11:12:24 +0100 Subject: [PATCH 07/14] added release and docker build workflows --- .github/workflows/docker-build.yml | 40 ++++++++++++++++++++++++++++++ .github/workflows/release.yml | 25 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 .github/workflows/docker-build.yml create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml new file mode 100644 index 000000000..6e017f0bb --- /dev/null +++ b/.github/workflows/docker-build.yml @@ -0,0 +1,40 @@ +name: Build and Push Docker Image to GitHub Container Registry + +on: + release: + types: [published] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Log in to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image to GitHub Container Registry + uses: docker/build-push-action@v4 + with: + context: . + file: ./Dockerfile + push: true + platforms: linux/amd64,linux/arm64 + tags: | + ghcr.io/${{ github.repository_owner }}/madara:latest + ghcr.io/${{ github.repository_owner }}/madara:${{ github.event.release.tag_name }} + labels: | + org.opencontainers.image.source=${{ github.repository.html_url }} + org.opencontainers.image.version=${{ github.event.release.tag_name }} + + - name: Post successful message + run: echo "Docker image built and pushed successfully" diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 000000000..d412f8aa6 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,25 @@ +name: Create Release + +on: + push: + tags: + - 'v*.*.*' # Triggers on version tags like v1.0.0 + +jobs: + create_release: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Create GitHub Release + uses: ncipollo/release-action@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref_name }} + name: Release ${{ github.ref_name }} + commit: ${{ github.sha }} + draft: false + prerelease: false + generateReleaseNotes: true From 80e6623eda7cce34f098441a8d0235db40d1e55f Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 11:17:02 +0100 Subject: [PATCH 08/14] changelog --- .github/workflows/release.yml | 2 +- CHANGELOG.md | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d412f8aa6..c0ad6b369 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,7 @@ name: Create Release on: push: tags: - - 'v*.*.*' # Triggers on version tags like v1.0.0 + - "v*.*.*" # Triggers on version tags like v1.0.0 jobs: create_release: diff --git a/CHANGELOG.md b/CHANGELOG.md index 506f81160..9f6756451 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## Next release +- feat(cli): launcher script and release workflows - fix: cleaned cli settings for sequencer, devnet and full - feat: move to karnot runner - fix: docker file fixes for devnet From a01f2dcb7873eaa0c1f5ab5e234621150b086dbd Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 11:37:59 +0100 Subject: [PATCH 09/14] updated release workflow --- .github/workflows/release.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index c0ad6b369..179c1af26 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,6 +5,9 @@ on: tags: - "v*.*.*" # Triggers on version tags like v1.0.0 +permissions: + contents: write # Add this line to grant write permissions to contents + jobs: create_release: runs-on: ubuntu-latest From 7866af55cea5e3e5e71d626ec5b5146a92f23144 Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 12:21:13 +0100 Subject: [PATCH 10/14] updated release workflow --- .github/workflows/release.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 2dfec8b99..a5c07eee5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,13 +5,11 @@ on: tags: - "v*.*.*" # Triggers on version tags like v1.0.0 -permissions: - contents: write - jobs: create_release: runs-on: ubuntu-latest - + permissions: + contents: write steps: - name: Checkout repository uses: actions/checkout@v3 @@ -19,10 +17,10 @@ jobs: - name: Create GitHub Release uses: ncipollo/release-action@v1 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.RELEASE_ACTION }} tag: ${{ github.ref_name }} name: Release ${{ github.ref_name }} commit: ${{ github.sha }} draft: false prerelease: false - generateReleaseNotes: true + generateReleaseNotes: true \ No newline at end of file From 22f4fc88a3e0bbdb50e79c239a9c6b45f043c3f8 Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 14:26:36 +0100 Subject: [PATCH 11/14] updated launcher and docker build release --- .github/workflows/docker-build.yml | 2 +- scripts/launcher | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 6e017f0bb..6d9608206 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -6,7 +6,7 @@ on: jobs: build: - runs-on: ubuntu-latest + runs-on: karnot-arc-runner-set steps: - name: Checkout repository diff --git a/scripts/launcher b/scripts/launcher index a8d849117..7196ec3a8 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -480,7 +480,6 @@ if [ "$RPC_ACCESS" == "yes" ]; then continue fi - # If everything is okay, break the loop break done @@ -508,12 +507,23 @@ done tput rc tput ed + +# Check if the image is available locally +IMAGE_NAME="ghcr.io/madara-alliance/madara/madara:latest" +if docker images --format "{{.Repository}}:{{.Tag}}" | grep -q "$IMAGE_NAME"; then + echo -e "\nπŸ“¦ ${GREEN}Docker image '$IMAGE_NAME' is already available locally.${NC}" +else + echo -e "\n🚒 ${YELLOW}${BOLD}Docker image not found locally. Pulling from GitHub Packages...${NC}" + docker login ghcr.io -u GITHUB_USERNAME -p GITHUB_TOKEN + docker pull $IMAGE_NAME +fi + # Build the final Docker run command DOCKER_COMMAND="docker run -d --name madara-node \ -v ${BASE_PATH}:/data \ ${PORT_MAPPING} \ - madara \ - run --${MODE} --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\"" + $IMAGE_NAME \ + --${MODE} --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\"" echo -e "\nπŸ”„ ${YELLOW}${BOLD}The following Docker command will be executed:${NC}\n" echo -e "${CYAN}$DOCKER_COMMAND${NC}" @@ -533,4 +543,4 @@ if [ "$CONFIRM" == "yes" ]; then echo -e "\n${GREEN}Madara node is now running in Docker container 'madara-node'.${NC}" else echo -e "${RED}Command execution aborted.${NC}" -fi +fi \ No newline at end of file From afde7527fc9f0f01722740897fe333bce145d331 Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 15:21:36 +0100 Subject: [PATCH 12/14] updated launcher --- .github/workflows/release.yml | 2 +- scripts/launcher | 78 ++++++++++++++++------------------- 2 files changed, 36 insertions(+), 44 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a5c07eee5..a550ce213 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,4 +23,4 @@ jobs: commit: ${{ github.sha }} draft: false prerelease: false - generateReleaseNotes: true \ No newline at end of file + generateReleaseNotes: true diff --git a/scripts/launcher b/scripts/launcher index 7196ec3a8..856531a42 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -266,42 +266,6 @@ else echo -e "\n${GREEN}All dependencies are successfully installed and verified.${NC}" fi -echo -e "\n${GREEN}We will now proceed with the download of Madara from GitHub:${NC}" -echo -e "${CYAN}${GITHUB_ICON}${UNDERLINE}https://github.com/madara-alliance/madara${NC}" - -# Ask for installation directory -echo -e "\n${YELLOW}${BOLD}Where would you like to install Madara? (default is current directory)${NC}" -read -p "> " INSTALL_DIR - -# Set default directory if not provided -INSTALL_DIR=${INSTALL_DIR:-$(pwd)} - -# Clone the Madara repository (this step should be removed when we have images available remotely) -echo -e "\n${GREEN}Cloning the Madara repository into ${INSTALL_DIR}...${NC}" -if [ -d "${INSTALL_DIR}/madara" ]; then - echo -e "${YELLOW}Madara directory already exists. Updating...${NC}" - cd "${INSTALL_DIR}/madara" && git pull -else - git clone https://github.com/madara-alliance/madara.git "${INSTALL_DIR}/madara" - git checkout fix/launcher-script - cd "${INSTALL_DIR}/madara" -fi - -tput rc -tput ed - -# Build the Docker image -echo -e "\n${GREEN}Building the Docker image... (this operation will take a few minutes)${NC}" -# if ! docker build -t madara .; then -# echo -e "${RED}Docker image build failed. Please check the Dockerfile and try again.${NC}" -# exit 1 -# fi - -tput rc -tput ed - -echo -e "\n${GREEN}Madara has been correctly installed here: ${BOLD}${INSTALL_DIR}${NC}${GREEN}.${NC}" - # Choose the mode echo -e "\nπŸ•ΉοΈ ${YELLOW}${BOLD} On which mode would you like to run Madara? (Enter a number)${NC}\n" echo "${YELLOW}1. Full Node${NC}" @@ -519,7 +483,7 @@ else fi # Build the final Docker run command -DOCKER_COMMAND="docker run -d --name madara-node \ +DOCKER_COMMAND="docker run -d --name madara-client \ -v ${BASE_PATH}:/data \ ${PORT_MAPPING} \ $IMAGE_NAME \ @@ -534,13 +498,41 @@ read -p "> " CONFIRM if [ "$CONFIRM" == "yes" ]; then echo -e "\n${GREEN}Starting the Madara node via Docker...${NC}" # Stop and remove any existing container with the same name - if docker ps -a --format '{{.Names}}' | grep -Eq "^madara-node\$"; then - echo -e "\n${YELLOW}A container named 'madara-node' already exists. Stopping and removing it...${NC}" - docker stop madara-node - docker rm madara-node + if docker ps -a --format '{{.Names}}' | grep -Eq "^madara-client\$"; then + echo -e "\n${YELLOW}A container named 'madara-client' already exists. Stopping and removing it...${NC}" + docker stop madara-client + docker rm madara-client fi eval $DOCKER_COMMAND - echo -e "\n${GREEN}Madara node is now running in Docker container 'madara-node'.${NC}" + tput rc + tput ed + # Check if the Madara Docker container is running + if docker ps --format '{{.Names}}' | grep -q '^madara-client$'; then + echo -e "\n${GREEN}Madara client is running.${NC}" + echo -e "${YELLOW}Container details:${NC}" + docker inspect madara-client --format ' + Name: {{.Name}} + ID: {{.Id}} + Image: {{.Config.Image}} + Status: {{.State.Status}} + StartedAt: {{.State.StartedAt}} + Ports: {{range $p, $conf := .NetworkSettings.Ports}}{{$p}}: {{(index $conf 0).HostPort}}{{end}}' + + echo -e "\n${YELLOW}Client Logs (last 10 lines):${NC}" + docker logs --tail 10 madara-client + + # Ask the user whether to quit or display more logs + echo -e "\n${YELLOW}${BOLD}Would you like to display the full logs of the running instance or quit? (logs/quit)${NC}\n" + read -p "> " USER_CHOICE + if [ "$USER_CHOICE" == "logs" ]; then + echo -e "\n${YELLOW}Displaying full logs...${NC}" + docker logs -f madara-client + else + echo -e "\n${GREEN}Exiting...${NC}" + fi + else + echo -e "${RED}Madara client is not running.${NC}" + fi else echo -e "${RED}Command execution aborted.${NC}" -fi \ No newline at end of file +fi From 4c6e13e8f8c8ac20c108549ebb30d12ce00c45ba Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 17:18:10 +0100 Subject: [PATCH 13/14] added chain config configuration --- scripts/launcher | 276 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 200 insertions(+), 76 deletions(-) diff --git a/scripts/launcher b/scripts/launcher index 856531a42..b70244030 100755 --- a/scripts/launcher +++ b/scripts/launcher @@ -82,6 +82,13 @@ echo -e "${RED} " } +# Preset Chain Config URLs +declare -A PRESET_URLS +PRESET_URLS["starknet_mainnet"]="https://raw.githubusercontent.com/madara-alliance/madara/main/configs/presets/mainnet.yaml" +PRESET_URLS["starknet_testnet"]="https://raw.githubusercontent.com/madara-alliance/madara/main/configs/presets/testnet.yaml" +PRESET_URLS["test"]="https://raw.githubusercontent.com/madara-alliance/madara/main/configs/presets/test.yaml" +PRESET_URLS["devnet"]="https://raw.githubusercontent.com/madara-alliance/madara/main/configs/presets/devnet.yaml" + # Welcome message clear ascii_art @@ -110,6 +117,7 @@ fi DEPENDENCIES=( "curl:command -v curl" "git:command -v git" + "yq:command -v yq" ) # Function to check for a dependency @@ -176,6 +184,12 @@ if [ ${#MISSING_DEPS[@]} -ne 0 ] || [ "$DOCKER_MISSING" = true ]; then if [ "$OS" == "Linux" ]; then sudo apt update for DEP in "${MISSING_DEPS[@]}"; do + if [ "$DEP" == "yq" ]; then + echo -e "${GREEN}Installing yq...${NC}" + sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/local/bin/yq + sudo chmod +x /usr/local/bin/yq + continue + fi if ! sudo apt install -y "$DEP"; then echo -e "${RED}Failed to install $DEP.${NC}" fi @@ -191,6 +205,13 @@ if [ ${#MISSING_DEPS[@]} -ne 0 ] || [ "$DOCKER_MISSING" = true ]; then fi elif [ "$OS" == "Mac" ]; then for DEP in "${MISSING_DEPS[@]}"; do + if [ "$DEP" == "yq" ]; then + echo -e "${GREEN}Installing yq via Homebrew...${NC}" + if ! brew install yq; then + echo -e "${RED}Failed to install yq.${NC}" + fi + continue + fi if ! brew install "$DEP"; then echo -e "${RED}Failed to install $DEP.${NC}" fi @@ -200,7 +221,7 @@ if [ ${#MISSING_DEPS[@]} -ne 0 ] || [ "$DOCKER_MISSING" = true ]; then if ! brew install --cask docker; then echo -e "${RED}Failed to install Docker.${NC}" else - echo -e "${GREEN}Docker installed.\nTrying to open /Applications/Docker.app to start the Docker daemon (you may need to do this step yourself if not located under /Applications/Docker.app).${NC}" + echo -e "${GREEN}Docker installed.\nTrying to open /Applications/Docker.app to start the Docker daemon.${NC}" open /Applications/Docker.app # Wait for Docker daemon to start echo -e "${GREEN}Waiting for Docker daemon to start...${NC}" @@ -227,7 +248,7 @@ if [ "$DOCKER_NOT_RUNNING" = true ]; then echo -e "${GREEN}Docker daemon is running.${NC}" fi elif [ "$OS" == "Mac" ]; then - echo -e "${GREEN}Docker installed.\nTrying to open /Applications/Docker.app to start the Docker daemon (you may need to do this step yourself if not located under /Applications/Docker.app).${NC}" + echo -e "${GREEN}Trying to open /Applications/Docker.app to start the Docker daemon.${NC}" open /Applications/Docker.app # Wait for Docker daemon to start echo -e "${GREEN}Waiting for Docker daemon to start...${NC}" @@ -267,7 +288,7 @@ else fi # Choose the mode -echo -e "\nπŸ•ΉοΈ ${YELLOW}${BOLD} On which mode would you like to run Madara? (Enter a number)${NC}\n" +echo -e "\nπŸ•ΉοΈ ${YELLOW}${BOLD}On which mode would you like to run Madara? (Enter a number)${NC}\n" echo "${YELLOW}1. Full Node${NC}" echo "${YELLOW}2. Sequencer${NC}" echo "${YELLOW}3. Devnet${NC}" @@ -302,114 +323,219 @@ tput ed echo -e "\n${GREEN}Your node has been correctly named: ${BOLD}${NODE_NAME}${NC}${GREEN}.${NC}" +# Ask for the database path +echo -e "\nπŸ’Ύ ${YELLOW}${BOLD}Where would you like to store your database? (default: /tmp/madara)${NC}" +read -p "> " BASE_PATH +BASE_PATH=${BASE_PATH:-/tmp/madara} + +tput rc +tput ed + +# Create the base path directory if it doesn't exist +if [ ! -d "$BASE_PATH" ]; then + mkdir -p "$BASE_PATH" +fi + +# Modify Chain Config Function +modify_chain_config() { + local config_file="$1" + local OVERRIDES_FILE="$BASE_PATH/overrides.txt" + > "$OVERRIDES_FILE" # Empty the overrides file + + # Read all leaf nodes with their paths and values + config_entries=() + while IFS= read -r line; do + config_entries+=("$line") + done < <(yq eval '.. | select(tag != "!!map" and tag != "!!seq") | [path | join("."), .] | @tsv' "$config_file") + + tput rc + tput ed + + # Display all parameters with improved formatting + echo -e "\n${YELLOW}${BOLD}Here are all the parameters of your chosen configuration:${NC}\n" + + prev_prefix="" + for i in "${!config_entries[@]}"; do + entry="${config_entries[$i]}" + path=$(echo "$entry" | cut -f1) + value=$(echo "$entry" | cut -f2-) + + # Extract the top-level prefix for grouping + prefix=$(echo "$path" | cut -d'.' -f1) + + # Add a new line and header when a new group starts + if [[ "$prefix" != "$prev_prefix" ]]; then + echo -e "${BLUE}${BOLD}$prefix:${NC}" + prev_prefix="$prefix" + fi + + # Indent sub-parameters + sub_path=$(echo "$path" | cut -d'.' -f2-) + if [[ -n "$sub_path" ]]; then + display_path=" - ${sub_path}" + else + display_path=" - $prefix" + fi + + echo -e "${YELLOW}$((i+1)). ${display_path} = ${value}${NC}" + done + + # Ask user which parameters to modify + echo -e "\n${YELLOW}Enter the numbers of the parameters you wish to modify, separated by spaces (e.g., 1 3 5).${NC}" + echo -e "${YELLOW}Press Enter to continue without modifying any parameters.${NC}" + read -p "> " MODIFY_NUMBERS + + # Check if the user wants to skip modifications + if [[ -z "$MODIFY_NUMBERS" ]]; then + echo -e "${GREEN}No parameters selected for modification. Proceeding with the original configuration.${NC}" + else + selected_indices=($MODIFY_NUMBERS) + + for index in "${selected_indices[@]}"; do + # Subtract 1 to convert to zero-based index + idx=$((index - 1)) + if [ "$idx" -ge 0 ] && [ "$idx" -lt "${#config_entries[@]}" ]; then + entry="${config_entries[$idx]}" + path=$(echo "$entry" | cut -f1) + value=$(echo "$entry" | cut -f2-) + echo -e "\n${YELLOW}Parameter: ${path}${NC}" + echo -e "${GREEN}Current value: ${value}${NC}" + echo -e "${YELLOW}Enter new value for ${path}:${NC}" + read -p "> " NEW_VALUE + echo "${path}=${NEW_VALUE}" >> "$OVERRIDES_FILE" + else + echo -e "${RED}Invalid selection: $index${NC}" + fi + done + fi + + # Apply the overrides to the original config file and write to $BASE_PATH/chain_config.yaml + MODIFIED_CONFIG_PATH="$BASE_PATH/chain_config.yaml" + cp "$config_file" "$MODIFIED_CONFIG_PATH" + + if [[ -s "$OVERRIDES_FILE" ]]; then + while IFS= read -r line; do + key=$(echo "$line" | cut -d'=' -f1) + val=$(echo "$line" | cut -d'=' -f2-) + yq eval -i ".${key} = \"${val}\"" "$MODIFIED_CONFIG_PATH" + done < "$OVERRIDES_FILE" + fi + + # Set CHAIN_CONFIG_FILE to the path of the modified chain config + CHAIN_CONFIG_FILE="$MODIFIED_CONFIG_PATH" +} + # Choose the network based on the mode -if [ "$MODE" == "Sequencer" ] || [ "$MODE" == "Devnet" ]; then +if [ "$MODE" == "sequencer" ] || [ "$MODE" == "devnet" ]; then # For sequencer and devnet modes echo -e "\n🌐 ${YELLOW}${BOLD}Please choose one of the available presets or provide a custom chain config path: (Enter a number)${NC}\n" echo "${YELLOW}1. Starknet Mainnet${NC}" echo "${YELLOW}2. Starknet Testnet${NC}" - echo "${YELLOW}3. Test${NC}" + echo "${YELLOW}3. Devnet${NC}" echo "${YELLOW}4. Custom Chain config${NC}" while true; do read -p "> " NETWORK_CHOICE case $NETWORK_CHOICE in - 1) PRESET="starknet_mainnet"; break ;; - 2) PRESET="starknet_testnet"; break ;; - 3) PRESET="test"; break ;; + 1) + PRESET="starknet_mainnet" + PRESET_URL="${PRESET_URLS[$PRESET]}" + ;; + 2) + PRESET="starknet_testnet" + PRESET_URL="${PRESET_URLS[$PRESET]}" + ;; + 3) + PRESET="devnet" + PRESET_URL="${PRESET_URLS[$PRESET]}" + ;; 4) echo -e "\n${YELLOW}Please provide the path to your custom chain config:${NC}" read -p "> " CUSTOM_CHAIN_CONFIG if [ -f "$CUSTOM_CHAIN_CONFIG" ]; then - PRESET="$CUSTOM_CHAIN_CONFIG" - break + PRESET="custom" + PRESET_PATH="$CUSTOM_CHAIN_CONFIG" else echo -e "${RED}File not found. Please provide a valid path.${NC}" + continue fi ;; - *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}" ;; + *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}"; continue ;; esac + + # Now, if a preset was selected (options 1-3), download the chain config file + if [ "$PRESET" != "custom" ]; then + # Download the chain config file to a temporary location + PRESET_PATH=$(mktemp) + curl -s -o "$PRESET_PATH" "$PRESET_URL" + if [ $? -ne 0 ] || [ ! -s "$PRESET_PATH" ]; then + echo -e "${RED}Failed to download the chain config file from $PRESET_URL.${NC}" + exit 1 + fi + fi + + # Call modify_chain_config with the chain config file + modify_chain_config "$PRESET_PATH" + break done else # For full node mode echo -e "\n🌐 ${YELLOW}${BOLD}Please choose a Network or provide a custom Chain config path: (Enter a number)${NC}\n" echo "${YELLOW}1. Starknet Mainnet${NC}" echo "${YELLOW}2. Starknet Testnet${NC}" - echo "${YELLOW}3. Starknet Integration${NC}" + echo "${YELLOW}3. Test${NC}" echo "${YELLOW}4. Custom Chain config${NC}" while true; do read -p "> " NETWORK_CHOICE case $NETWORK_CHOICE in - 1) NETWORK="main"; break ;; - 2) NETWORK="test"; break ;; - 3) NETWORK="integration"; break ;; + 1) + NETWORK="main" + PRESET="starknet_mainnet" + PRESET_URL="${PRESET_URLS[$PRESET]}" + ;; + 2) + NETWORK="test" + PRESET="starknet_testnet" + PRESET_URL="${PRESET_URLS[$PRESET]}" + ;; + 3) + NETWORK="test" + PRESET="test" + PRESET_URL="${PRESET_URLS[$PRESET]}" + ;; 4) - tput rc - tput ed - - echo -e "\n${GREEN}You have chosen to run your node under a custom Chain config.${NC}" - - echo -e "\n${YELLOW}${BOLD}🌐 Please choose one of the available presets or provide a custom chain config path: (Enter a number)${NC}\n" - echo "${YELLOW}1. Starknet Mainnet${NC}" - echo "${YELLOW}2. Starknet Testnet${NC}" - echo "${YELLOW}3. Test${NC}" - echo "${YELLOW}4. Custom Chain config${NC}" - while true; do - read -p "> " NETWORK_CHOICE - case $NETWORK_CHOICE in - 1) PRESET="starknet_mainnet"; break ;; - 2) PRESET="starknet_testnet"; break ;; - 3) PRESET="test"; break ;; - 4) - echo -e "\n${YELLOW}Please provide the path to your custom chain config:${NC}" - read -p "> " CUSTOM_CHAIN_CONFIG - if [ -f "$CUSTOM_CHAIN_CONFIG" ]; then - PRESET="$CUSTOM_CHAIN_CONFIG" - break - else - echo -e "${RED}File not found. Please provide a valid path.${NC}" - fi - ;; - *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}" ;; - esac - done + echo -e "\n${YELLOW}Please provide the path to your custom chain config:${NC}" + read -p "> " CUSTOM_CHAIN_CONFIG + if [ -f "$CUSTOM_CHAIN_CONFIG" ]; then + NETWORK="custom" + PRESET_PATH="$CUSTOM_CHAIN_CONFIG" + else + echo -e "${RED}File not found. Please provide a valid path.${NC}" + continue + fi ;; - *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}" ;; + *) echo -e "${YELLOW}Invalid choice, please enter 1, 2, 3, or 4.${NC}"; continue ;; esac - done -fi -tput rc -tput ed - -echo -e "\n${GREEN}You have chosen to run your node under: ${NETWORK}.${NC}" + # For options 1-3, download the chain config file and call modify_chain_config + if [ "$NETWORK" != "custom" ]; then + PRESET_PATH=$(mktemp) + curl -s -o "$PRESET_PATH" "$PRESET_URL" + if [ $? -ne 0 ] || [ ! -s "$PRESET_PATH" ]; then + echo -e "${RED}Failed to download the chain config file from $PRESET_URL.${NC}" + exit 1 + fi + fi -# Set the chain config or network option -if [ "$MODE" == "Sequencer" ] || [ "$MODE" == "Devnet" ]; then - # Use --chain-config with PRESET - CHAIN_CONFIG_OPT="--chain-config=\"${PRESET}\"" -else - # For full node mode - if [ "$NETWORK_CHOICE" -eq 4 ]; then - # Custom chain config - CHAIN_CONFIG_OPT="--chain-config=\"${NETWORK}\"" - else - # Use --network - CHAIN_CONFIG_OPT="--network=\"${NETWORK}\"" - fi + # Call modify_chain_config with the chain config file + modify_chain_config "$PRESET_PATH" + break + done fi -# Ask for the database path -echo -e "\nπŸ’Ύ ${YELLOW}${BOLD}Where would you like to store your database? (default: /tmp/madara)${NC}" -read -p "> " BASE_PATH -BASE_PATH=${BASE_PATH:-/tmp/madara} - tput rc tput ed -# Create the base path directory if it doesn't exist -if [ ! -d "$BASE_PATH" ]; then - mkdir -p "$BASE_PATH" -fi +echo -e "\n${GREEN}You have chosen to run your node under the preset or custom chain config.${NC}" # Ask for RPC access while true; do @@ -471,14 +597,12 @@ done tput rc tput ed - # Check if the image is available locally IMAGE_NAME="ghcr.io/madara-alliance/madara/madara:latest" if docker images --format "{{.Repository}}:{{.Tag}}" | grep -q "$IMAGE_NAME"; then echo -e "\nπŸ“¦ ${GREEN}Docker image '$IMAGE_NAME' is already available locally.${NC}" else echo -e "\n🚒 ${YELLOW}${BOLD}Docker image not found locally. Pulling from GitHub Packages...${NC}" - docker login ghcr.io -u GITHUB_USERNAME -p GITHUB_TOKEN docker pull $IMAGE_NAME fi @@ -487,7 +611,7 @@ DOCKER_COMMAND="docker run -d --name madara-client \ -v ${BASE_PATH}:/data \ ${PORT_MAPPING} \ $IMAGE_NAME \ - --${MODE} --name \"${NODE_NAME}\" ${CHAIN_CONFIG_OPT} --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\"" + --${MODE} --name \"${NODE_NAME}\" --chain-config=\"/data/chain_config.yaml\" --base-path=\"/data\" ${RPC_OPTS} --l1-endpoint \"${L1_ENDPOINT}\"" echo -e "\nπŸ”„ ${YELLOW}${BOLD}The following Docker command will be executed:${NC}\n" echo -e "${CYAN}$DOCKER_COMMAND${NC}" From 1b8b45f4d9fad0e90d0948ced3b700c7fb71c641 Mon Sep 17 00:00:00 2001 From: antiyro Date: Tue, 1 Oct 2024 17:36:16 +0100 Subject: [PATCH 14/14] optimized docker build and launcher --- .github/workflows/docker-build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 6d9608206..9cc8da280 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -12,6 +12,9 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2 @@ -35,6 +38,8 @@ jobs: labels: | org.opencontainers.image.source=${{ github.repository.html_url }} org.opencontainers.image.version=${{ github.event.release.tag_name }} + cache-from: type=gha + cache-to: type=gha,mode=max - name: Post successful message run: echo "Docker image built and pushed successfully"