diff --git a/.github/workflows/docker.yaml b/.github/workflows/deployment.yaml similarity index 67% rename from .github/workflows/docker.yaml rename to .github/workflows/deployment.yaml index 9f43f29e7..d06c024ec 100644 --- a/.github/workflows/docker.yaml +++ b/.github/workflows/deployment.yaml @@ -1,4 +1,4 @@ -name: Build docker image +name: Deployment on: push: @@ -38,6 +38,12 @@ jobs: context: ./ file: ./Dockerfile push: true - tags: | - ${{ steps.docker-image.outputs.image }}:latest - ${{ steps.docker-image.outputs.image }}:${{ github.sha }} + tags: ${{ steps.docker-image.outputs.image }}:${{ github.sha }} + + - name: Deploy to CodeDeploy + run: | + aws deploy create-deployment \ + --application-name ${{ secrets.AWS_CODEDEPLOY_APPLICATION_NAME }} \ + --deployment-group-name ${{ secrets.AWS_CODEDEPLOY_DEPLOYMENT_GROUP }} \ + --github-location repository=${{ github.repository }},commitId=${{ github.sha }} \ + --description "Deploying Across Relayer Docker image to EC2 instance" diff --git a/scripts/lisk/docker/composeStop.sh b/scripts/lisk/docker/composeStop.sh index 2fa3eee97..71b800a8e 100644 --- a/scripts/lisk/docker/composeStop.sh +++ b/scripts/lisk/docker/composeStop.sh @@ -5,6 +5,4 @@ set -eu . $(dirname "$0")/setEnvVariables.sh -# Wait for the CI to build and push the Docker image to ECR -sleep 300 docker compose down --rmi all diff --git a/scripts/lisk/installApplication.sh b/scripts/lisk/installApplication.sh deleted file mode 100644 index e8fb48ec2..000000000 --- a/scripts/lisk/installApplication.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# Load NVM -export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" -[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - -# Change to application directory -app_dir_name=/home/ubuntu/lisk-across-relayer -cd $app_dir_name -echo "Current DIR: $PWD" - -# Install application -nvm use -yarn install --frozen-lockfile -yarn build \ No newline at end of file diff --git a/scripts/lisk/installDependencies.sh b/scripts/lisk/installDependencies.sh deleted file mode 100644 index efe947eba..000000000 --- a/scripts/lisk/installDependencies.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/bash -# Script to install Node.js using NVM on Ubuntu - -app_dir_name=/home/ubuntu/lisk-across-relayer -cd $app_dir_name -echo "Current DIR: $PWD" - -# Read node version from .nvmrc file -node_version=$(cat .nvmrc | tr -d "\n") -if [[ -z "${node_version-}" ]]; -then - echo ".nvmrc not found; exiting..." - exit 1 -fi - -# Function to install NVM -install_nvm() { - curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash -} - -install_node_version() { - # Check if NVM is installed - export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" - if [ -s "$NVM_DIR/nvm.sh" ]; - then - echo "NVM is already installed." - else - echo "Installing NVM..." - install_nvm - fi - - # Load NVM - [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" - - echo "Installing Node version $node_version..." - nvm install $node_version - nvm alias default $node_version -} - -install_node_version -echo "Node.js version $node_version has been installed." - -# Install yarn -npm install --global yarn - -# Install pm2 -npm install --global pm2@latest \ No newline at end of file diff --git a/scripts/lisk/runMainnet.sh b/scripts/lisk/runMainnet.sh deleted file mode 100644 index a65deefc4..000000000 --- a/scripts/lisk/runMainnet.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -app_dir=/home/ubuntu/lisk-across-relayer -cd $app_dir -echo "Current DIR: $PWD" - -# Remove previous .env var if any -rm -vf .env - -# Setting env var from secrets -secret_id=arn:aws:secretsmanager:eu-west-3:132202091885:secret:mainnet/lisk-across-relayer/aws-CSi7ka -RELAYER_CONFIG=`aws --region eu-west-3 secretsmanager get-secret-value --secret-id ${secret_id} | jq --raw-output .SecretString | jq -r .` - -AWSKMS_CONFIG=`echo $RELAYER_CONFIG | jq -r ."AWSKMS_CONFIG"` -echo "AWSKMS_CONFIG=$AWSKMS_CONFIG" >> .env - -AWS_S3_STORAGE_CONFIG=`echo $RELAYER_CONFIG | jq -r ."AWS_S3_STORAGE_CONFIG"` -echo "AWS_S3_STORAGE_CONFIG=$AWS_S3_STORAGE_CONFIG" >> ${app_dir}/.env - -RPC_PROVIDER_DRPC_1=`echo $RELAYER_CONFIG | jq -r ."RPC_PROVIDER_DRPC_1"` -echo "RPC_PROVIDER_DRPC_1=$RPC_PROVIDER_DRPC_1" >> ${app_dir}/.env - -RPC_PROVIDER_TENDERLY_1=`echo $RELAYER_CONFIG | jq -r ."RPC_PROVIDER_TENDERLY_1"` -echo "RPC_PROVIDER_TENDERLY_1=$RPC_PROVIDER_TENDERLY_1" >> ${app_dir}/.env - -RPC_PROVIDER_DRPC_1135=`echo $RELAYER_CONFIG | jq -r ."RPC_PROVIDER_DRPC_1135"` -echo "RPC_PROVIDER_DRPC_1135=$RPC_PROVIDER_DRPC_1135" >> ${app_dir}/.env - -RPC_PROVIDER_GELATO_1135=`echo $RELAYER_CONFIG | jq -r ."RPC_PROVIDER_GELATO_1135"` -echo "RPC_PROVIDER_GELATO_1135=$RPC_PROVIDER_GELATO_1135" >> ${app_dir}/.env - -API_SERVER_HOST=`echo $RELAYER_CONFIG | jq -r ."API_SERVER_HOST"` -echo "API_SERVER_HOST=$API_SERVER_HOST" >> ${app_dir}/.env - -SLACK_CONFIG=`echo $RELAYER_CONFIG | jq -r ."SLACK_CONFIG"` -echo "SLACK_CONFIG=$SLACK_CONFIG" >> ${app_dir}/.env - -echo "All env vars from secrets are set." - -# Set the bot identifier -echo "BOT_IDENTIFIER=LISK_ACROSS_RELAYER" >> ${app_dir}/.env - -# Simulation mode OFF -echo "SEND_RELAYS=true" >> ${app_dir}/.env -echo "SEND_REBALANCES=true" >> ${app_dir}/.env - -# RPC provider configuration -echo "RPC_PROVIDERS=DRPC,GELATO,TENDERLY" >> ${app_dir}/.env -echo "RPC_PROVIDERS_1=DRPC,TENDERLY" >> ${app_dir}/.env -echo "RPC_PROVIDERS_1135=GELATO,DRPC" >> ${app_dir}/.env - -# Mainnet settings -echo "RELAYER_ORIGIN_CHAINS=[1,1135]" >> ${app_dir}/.env -echo "RELAYER_DESTINATION_CHAINS=[1,1135]" >> ${app_dir}/.env -echo "MIN_RELAYER_FEE_PCT=0.00005" >> ${app_dir}/.env - -# Fee settings -echo "PRIORITY_FEE_SCALER_1=0.8" >> ${app_dir}/.env -echo "RELAYER_GAS_PADDING=0" >> ${app_dir}/.env - -# Redis settings -echo "REDIS_URL='redis://127.0.0.1:6379'" >> ${app_dir}/.env - -# Supported token settings -echo RELAYER_TOKENS=\'[\"0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2\", \"0x6033F7f88332B8db6ad452B7C6D5bB643990aE3f\", \"0xdAC17F958D2ee523a2206206994597C13D831ec7\"]\' >> ${app_dir}/.env -echo MIN_DEPOSIT_CONFIRMATIONS=\'{\"5000\": { \"1\": 5, \"1135\": 10 }, \"2000\": { \"1\": 4, \"1135\": 10 }, \"100\": { \"1\": 3, \"1135\": 10 } }\' >> ${app_dir}/.env -echo RELAYER_EXTERNAL_INVENTORY_CONFIG=\'config/mainnet/relayerExternalInventory.json\' >> ${app_dir}/.env - -echo "All env vars are set." - -# PM2 runs on the fall back path when using CodeDeploy agent and we can run with the given fall back path -export PM2_HOME=/etc/.pm2 -pm2 delete all # Delete any running app -pm2 start --name "lisk-across-relayer" "node ${app_dir}/dist/index.js --relayer --wallet awskms --keys "relayerKey"" \ No newline at end of file diff --git a/scripts/lisk/runSepolia.sh b/scripts/lisk/runSepolia.sh deleted file mode 100644 index 370993ffc..000000000 --- a/scripts/lisk/runSepolia.sh +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/bash -app_dir=/home/ubuntu/lisk-across-relayer -cd $app_dir -echo "Current DIR: $PWD" - -# Remove previous .env var if any -rm -vf .env - -# Setting env var from secrets -secret_id=arn:aws:secretsmanager:eu-west-3:132202091885:secret:testnet/lisk-across-relayer/aws-WBAwo1 -RELAYER_CONFIG=`aws --region eu-west-3 secretsmanager get-secret-value --secret-id ${secret_id} | jq --raw-output .SecretString | jq -r .` - -AWSKMS_CONFIG=`echo $RELAYER_CONFIG | jq -r ."AWSKMS_CONFIG"` -echo "AWSKMS_CONFIG=$AWSKMS_CONFIG" >> .env - -AWS_S3_STORAGE_CONFIG=`echo $RELAYER_CONFIG | jq -r ."AWS_S3_STORAGE_CONFIG"` -echo "AWS_S3_STORAGE_CONFIG=$AWS_S3_STORAGE_CONFIG" >> ${app_dir}/.env - -RPC_PROVIDER_DRPC_11155111=`echo $RELAYER_CONFIG | jq -r ."RPC_PROVIDER_DRPC_11155111"` -echo "RPC_PROVIDER_DRPC_11155111=$RPC_PROVIDER_DRPC_11155111" >> ${app_dir}/.env - -RPC_PROVIDER_TENDERLY_11155111=`echo $RELAYER_CONFIG | jq -r ."RPC_PROVIDER_TENDERLY_11155111"` -echo "RPC_PROVIDER_TENDERLY_11155111=$RPC_PROVIDER_TENDERLY_11155111" >> ${app_dir}/.env - -RPC_PROVIDER_DRPC_4202=`echo $RELAYER_CONFIG | jq -r ."RPC_PROVIDER_DRPC_4202"` -echo "RPC_PROVIDER_DRPC_4202=$RPC_PROVIDER_DRPC_4202" >> ${app_dir}/.env - -RPC_PROVIDER_GELATO_4202=`echo $RELAYER_CONFIG | jq -r ."RPC_PROVIDER_GELATO_4202"` -echo "RPC_PROVIDER_GELATO_4202=$RPC_PROVIDER_GELATO_4202" >> ${app_dir}/.env - -echo "All env vars from secrets are set." - -# Set the bot identifier -echo "BOT_IDENTIFIER=LISK_ACROSS_RELAYER" >> ${app_dir}/.env - -# Simulation mode ON -echo "SEND_RELAYS=true" >> ${app_dir}/.env - -# RPC provider configuration -echo "RPC_PROVIDERS=TENDERLY,GELATO,DRPC" >> ${app_dir}/.env -echo "RPC_PROVIDERS_11155111=TENDERLY,DRPC" >> ${app_dir}/.env -echo "RPC_PROVIDERS_4202=GELATO,DRPC" >> ${app_dir}/.env - -# Sepolia testnet settings -echo "RELAYER_IGNORE_LIMITS=true" >> ${app_dir}/.env -echo "HUB_CHAIN_ID=11155111" >> ${app_dir}/.env -echo "RELAYER_ORIGIN_CHAINS=[11155111,4202]" >> ${app_dir}/.env -echo "RELAYER_DESTINATION_CHAINS=[11155111,4202]" >> ${app_dir}/.env - -# Redis settings -echo "REDIS_URL='redis://127.0.0.1:6379'" >> ${app_dir}/.env - -# Supported token settings -echo RELAYER_TOKENS=\'[\"0x16B840bA01e2b05fc2268eAf6d18892a11EC29D6\", \"0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0\", \"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14\"]\' >> ${app_dir}/.env -echo MIN_DEPOSIT_CONFIRMATIONS=\'{ \"1000000\": { \"919\": 1, \"4202\": 1, \"80002\": 1, \"84532\": 1, \"421614\": 1, \"11155111\": 1, \"11155420\": 1 } }\' >> ${app_dir}/.env - -echo "All env vars are set." - -# PM2 runs on the fall back path when using CodeDeploy agent and we can run with the given fall back path -export PM2_HOME=/etc/.pm2 -sudo -E pm2 delete all # Delete any running app -sudo -E pm2 start --name "lisk-across-relayer" "node ${app_dir}/dist/index.js --relayer --wallet awskms --keys "relayerKey"" \ No newline at end of file diff --git a/scripts/lisk/runSepoliaSimulationMode.sh b/scripts/lisk/runSepoliaSimulationMode.sh deleted file mode 100644 index 10557b743..000000000 --- a/scripts/lisk/runSepoliaSimulationMode.sh +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/bash -app_dir=/home/ubuntu/lisk-across-relayer -cd $app_dir -echo "Current DIR: $PWD" - -# Remove previous .env var if any -rm -vf .env - -# Setting env var from secrets -secret_id=arn:aws:secretsmanager:eu-west-3:132202091885:secret:testnet/lisk-across-relayer/aws-WBAwo1 -RELAYER_CONFIG=`aws --region eu-west-3 secretsmanager get-secret-value --secret-id ${secret_id} | jq --raw-output .SecretString | jq -r .` - -AWSKMS_CONFIG=`echo $RELAYER_CONFIG | jq -r ."AWSKMS_CONFIG"` -echo "AWSKMS_CONFIG=$AWSKMS_CONFIG" >> .env - -AWS_S3_STORAGE_CONFIG=`echo $RELAYER_CONFIG | jq -r ."AWS_S3_STORAGE_CONFIG"` -echo "AWS_S3_STORAGE_CONFIG=$AWS_S3_STORAGE_CONFIG" >> ${app_dir}/.env - -RPC_PROVIDER_DRPC_11155111=`echo $RELAYER_CONFIG | jq -r ."RPC_PROVIDER_DRPC_11155111"` -echo "RPC_PROVIDER_DRPC_11155111=$RPC_PROVIDER_DRPC_11155111" >> ${app_dir}/.env - -RPC_PROVIDER_TENDERLY_11155111=`echo $RELAYER_CONFIG | jq -r ."RPC_PROVIDER_TENDERLY_11155111"` -echo "RPC_PROVIDER_TENDERLY_11155111=$RPC_PROVIDER_TENDERLY_11155111" >> ${app_dir}/.env - -RPC_PROVIDER_DRPC_4202=`echo $RELAYER_CONFIG | jq -r ."RPC_PROVIDER_DRPC_4202"` -echo "RPC_PROVIDER_DRPC_4202=$RPC_PROVIDER_DRPC_4202" >> ${app_dir}/.env - -RPC_PROVIDER_GELATO_4202=`echo $RELAYER_CONFIG | jq -r ."RPC_PROVIDER_GELATO_4202"` -echo "RPC_PROVIDER_GELATO_4202=$RPC_PROVIDER_GELATO_4202" >> ${app_dir}/.env - -echo "All env vars from secrets are set." - -# Simulation mode ON -echo "SEND_RELAYS=false" >> ${app_dir}/.env -# RPC provider configuration -echo "RPC_PROVIDERS=TENDERLY,GELATO,DRPC" >> ${app_dir}/.env -echo "RPC_PROVIDERS_11155111=TENDERLY,DRPC" >> ${app_dir}/.env -echo "RPC_PROVIDERS_4202=GELATO,DRPC" >> ${app_dir}/.env - -# Sepolia testnet settings -echo "RELAYER_IGNORE_LIMITS=true" >> ${app_dir}/.env -echo "HUB_CHAIN_ID=11155111" >> ${app_dir}/.env -echo "RELAYER_ORIGIN_CHAINS=[11155111,4202]" >> ${app_dir}/.env -echo "RELAYER_DESTINATION_CHAINS=[11155111,4202]" >> ${app_dir}/.env -# Redis settings -echo "REDIS_URL='redis://127.0.0.1:6379'" >> ${app_dir}/.env -# Supported token settings -echo RELAYER_TOKENS=\'[\"0x16B840bA01e2b05fc2268eAf6d18892a11EC29D6\", \"0xaA8E23Fb1079EA71e0a56F48a2aA51851D8433D0\", \"0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14\"]\' >> ${app_dir}/.env -echo MIN_DEPOSIT_CONFIRMATIONS=\'{ \"1000000\": { \"919\": 1, \"4202\": 1, \"80002\": 1, \"84532\": 1, \"421614\": 1, \"11155111\": 1, \"11155420\": 1 } }\' >> ${app_dir}/.env - -echo "All env vars are set." - -# PM2 runs on the fall back path when using CodeDeploy agent and we can run with the given fall back path -export PM2_HOME=/etc/.pm2 -sudo -E pm2 delete all # Delete any running app -sudo -E pm2 start --name "lisk-across-relayer" "node ${app_dir}/dist/index.js --relayer --wallet awskms --keys "relayerKey"" \ No newline at end of file