From 76864f873787899c25a05b45a91aee5914d4ebe1 Mon Sep 17 00:00:00 2001 From: Michael Feng Date: Mon, 19 Jun 2023 15:10:47 -0700 Subject: [PATCH] (docs) remove old docker scripts and update readme --- README.md | 31 +++---- docker/README.md | 68 -------------- docker/gateway-copy-certs.sh | 89 ------------------ docker/gateway-create.sh | 172 ----------------------------------- 4 files changed, 11 insertions(+), 349 deletions(-) delete mode 100644 docker/README.md delete mode 100755 docker/gateway-copy-certs.sh delete mode 100755 docker/gateway-create.sh diff --git a/README.md b/README.md index 59d2a50040..082bb47e12 100644 --- a/README.md +++ b/README.md @@ -6,15 +6,15 @@ Hummingbot Gateway is a REST API that exposes connections to various blockchains Gateway may be used alongside the main [Hummingbot client](https://github.com/hummingbot/hummingbot) to enable trading on DEXs, or as a standalone module by external developers. -## Installation +## Installation via Docker -### Generate certificates +If you are installing Gateway alongside Hummingbot, check out the [Deploy Examples](https://github.com/hummingbot/deploy-examples) repository that helps you deployg various Hummingbot and Gateway configurations. -To run Gateway in `https` (default): -* **CERTS_PATH**: path to folder where Hummingbot generated and saved self-signed SSL certificates -* **PASSPHRASE**: passphrase used to generate the certificates above +For most new users, we recommend following the process outlined here: [Hummingbot Gateway Compose](https://github.com/hummingbot/deploy-examples/tree/main/hummingbot_gateway_compose) -### Run Gateway from source +[Bash scripts](https://github.com/hummingbot/deploy-examples/tree/main/bash_scripts) that help you install the Gateway Docker image are also found in the same repo. + +## Installation from source Dependencies: * NodeJS (16.0.0 or higher) @@ -35,18 +35,7 @@ $ ./gateway-setup.sh $ yarn start --passphrase= ``` -### Run Gateway using Docker - -Dependencies: -* [Docker](https://docker.com) - -See the [`/docker`](./docker) folder for Docker installation scripts and instructions on how to use them. - - -### Build Gateway Docker Image locally - -Dependencies: -* [Docker](https://docker.com) +### Build Docker image To build the gateway docker image locally execute the below make command: @@ -84,14 +73,16 @@ There are a number of ways to contribute to gateway. ### Configuration -- Edit `certs_path` in [conf/server.yml](./conf/server.yml) and enter the absolute path to the folder where Hummingbot stored the certificates it created with `gateway generate-certs`. You can also edit this config inside the Hummingbot client by running the command: `gateway config server.certs_path`. - - If you want to turn off `https`, set `unsafeDevModeWithHTTP` to `true` in [conf/server.yml](./conf/server.yml). - If you want Gateway to log to standard out, set `logToStdOut` to `true` in [conf/server.yml](./conf/server.yml). - The format of configuration files are dictated by [src/services/config-manager-v2.ts](./src/services/config-manager-v2.ts) and the corresponding schema files in [src/services/schema](./src/services/schema). +- If you want to turn off `https`, set `unsafeDevModeWithHTTP` to `true` in [conf/server.yml](./conf/server.yml). + +- For each supported chain, token lists that translate address to symbols for each chain are stored in `/conf/lists`. You can add tokens here to make them available to Gateway. + ### Architecture diff --git a/docker/README.md b/docker/README.md deleted file mode 100644 index 43435f9f54..0000000000 --- a/docker/README.md +++ /dev/null @@ -1,68 +0,0 @@ -# Docker commands - -## Setup - -The followings scripts assume that [Docker](https://www.docker.com/) has already been installed. - -They also assume that the user has Docker permissions without requiring `sudo`. If you do not have these permissions: - -1. Enter the following command: - - ``` - sudo usermod -a -G docker $USER - ``` - -2. Log out and log back into your console to enable them. - -## Installation Scripts - -### Linux -``` -wget https://raw.githubusercontent.com/hummingbot/gateway/main/docker/gateway-create.sh -wget https://raw.githubusercontent.com/hummingbot/gateway/main/docker/gateway-copy-certs.sh -chmod a+x *.sh -``` - -### MacOS -``` -curl https://raw.githubusercontent.com/hummingbot/gateway/main/docker/gateway-create.sh -o gateway-create.sh -curl https://raw.githubusercontent.com/hummingbot/gateway/main/docker/gateway-copy-certs.sh -o gateway-copy-certs.sh -chmod a+x *.sh -``` - -### Windows (WSL) - -This assumes that the user is using Windows Subsystem for Linux (WSL): - -``` -cd ~ -curl https://raw.githubusercontent.com/hummingbot/gateway/main/docker/gateway-create.sh -o gateway-create.sh -curl https://raw.githubusercontent.com/hummingbot/gateway/main/docker/gateway-copy-certs.sh.sh -o gateway-copy-certs.sh.sh -chmod a+x *.sh -``` - -## Create Gateway Instance - -The `gateway-create.sh` script helps you pull, configure, and run the Gateway Docker image. - -``` -./gateway-create.sh -``` - -## Copy Hummingbot Certs - -If you didn't do this step during `gateway-create.sh`, the `gateway-copy-certs.sh` script helps you copy the SSL certificates generated by Hummingbot into your Gateway files `certs` folder. This lets your Hummingbot instance access Gateway securely. - -``` -./gateway-copy-certs.sh -``` - -## Useful Commands - -These commands assume a Gateway container with the default instance name `gateway`: - -* List all Gateway containers: `docker ps -a --filter ancestor=hummingbot/gateway` -* Start Gateway container and attach to it: `docker start gateway && docker attach gateway` -* Stop Gateway container: `docker stop gateway` -* Update Gateway container to latest version: `docker pull hummingbot/gateway:latest` -* Remove Gateway container: `docker rm gateway` diff --git a/docker/gateway-copy-certs.sh b/docker/gateway-copy-certs.sh deleted file mode 100755 index 640684d3dd..0000000000 --- a/docker/gateway-copy-certs.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash -# init -# ============================================= - -echo -echo -echo "=============== COPY CERTS TO GATEWAY FOLDER ===============" -echo -echo "ℹ️ Press [ENTER] for default values:" -echo - -# Ask for Gateway instance name -echo "List of all Gateway containers:" -docker ps -a --filter ancestor=hummingbot/gateway -echo -read -p "Enter Gateway container name (default = \"gateway\") >>> " INSTANCE_NAME -echo -if [ "$INSTANCE_NAME" == "" ] -then - INSTANCE_NAME="gateway" -fi -DEFAULT_FOLDER="${INSTANCE_NAME}_files/certs" -echo -echo "Stopping container: $INSTANCE_NAME" -docker stop $INSTANCE_NAME - -# Ask for path to Hummingbot certs folder -read -p "Enter path to the Hummingbot certs folder >>> " CERTS_FROM_PATH -if [ ! -d "$CERTS_FROM_PATH" ]; then - echo "Error: $CERTS_FROM_PATH does not exist or is not a directory" - exit -fi - -# Ask for path to Gateway files folder -read -p "Enter path to the Gateway certs folder (default = \"./gateway-files/certs/\") >>> " FOLDER -if [ "$FOLDER" == "" ] -then - FOLDER=$PWD/$DEFAULT_FOLDER -elif [[ ${FOLDER::1} != "/" ]]; then - FOLDER=$PWD/$FOLDER -fi -CERTS_TO_PATH="$FOLDER" - -prompt_proceed () { - read -p "Do you want to proceed? [Y/N] >>> " PROCEED - if [ "$PROCEED" == "" ] - then - prompt_proceed - else - if [[ "$PROCEED" != "Y" && "$PROCEED" != "y" ]] - then - PROCEED="N" - fi - fi -} - -copy_certs () { - # Copy all files in the source folder to the destination folder - cp -r $CERTS_FROM_PATH/* $CERTS_TO_PATH/ - - # Confirm that the files were copied - echo - if [ $? -eq 0 ]; then - echo "Files successfully copied from $CERTS_FROM_PATH to $CERTS_TO_PATH" - else - echo "Error copying files from $CERTS_FROM_PATH to $CERTS_TO_PATH" - exit - fi - - echo "Starting container: $INSTANCE_NAME" - docker start $INSTANCE_NAME && docker attach $INSTANCE_NAME - echo -} - -# Ask user to confirm and proceed -echo -echo "ℹ️ Confirm if this is correct:" -echo -printf "%30s %5s\n" "Copy certs FROM:" "$CERTS_FROM_PATH" -printf "%30s %5s\n" "Copy certs TO:" "$CERTS_TO_PATH" -echo -prompt_proceed -if [[ "$PROCEED" == "Y" || "$PROCEED" == "y" ]] -then - copy_certs -else - echo "Exiting..." - exit -fi diff --git a/docker/gateway-create.sh b/docker/gateway-create.sh deleted file mode 100755 index aa3ea67a4c..0000000000 --- a/docker/gateway-create.sh +++ /dev/null @@ -1,172 +0,0 @@ -#!/bin/bash -# init - -echo -echo -echo "=============== CREATE A NEW GATEWAY INSTANCE ===============" -echo -echo -echo "ℹ️ Press [ENTER] for default values:" -echo - -echo -read -p "Enter Gateway version you want to use [latest/development] (default = \"latest\") >>> " GATEWAY_TAG -if [ "$GATEWAY_TAG" == "" ] -then - GATEWAY_TAG="latest" -fi - -# Ask the user for the name of the new Gateway instance -read -p "Enter a name for your new Gateway instance (default = \"gateway\") >>> " INSTANCE_NAME -if [ "$INSTANCE_NAME" == "" ] -then - INSTANCE_NAME="gateway" - DEFAULT_FOLDER="gateway_files" -else - DEFAULT_FOLDER="${INSTANCE_NAME}_files" -fi - -# Ask the user for the folder location to save files -read -p "Enter the folder name where your Gateway files will be saved (default = \"$DEFAULT_FOLDER\") >>> " FOLDER -if [ "$FOLDER" == "" ] -then - FOLDER=$PWD/$DEFAULT_FOLDER -elif [[ ${FOLDER::1} != "/" ]]; then - FOLDER=$PWD/$FOLDER -fi -CONF_FOLDER="$FOLDER/conf" -LOGS_FOLDER="$FOLDER/logs" -CERTS_FOLDER="$FOLDER/certs" - - -# Ask the user for the hummingbot certs passphrase -prompt_passphrase () { -echo -read -s -p "Enter the passphrase you used to generate certificates in Hummingbot >>> " PASSPHRASE -if [ "$PASSPHRASE" == "" ] -then - echo - echo - echo "!! Error: passphrase cannot be blank" - prompt_passphrase -fi -} -prompt_passphrase - -# Get GMT offset from local system time -GMT_OFFSET=$(date +%z) - -# Check available open port for Gateway -GATEWAY_PORT=15888 -LIMIT=$((GATEWAY_PORT+1000)) -while [[ $GATEWAY_PORT -le LIMIT ]] - do - if [[ $(netstat -nat | grep "$GATEWAY_PORT") ]]; then - # check another port - ((GATEWAY_PORT = GATEWAY_PORT + 1)) - else - break - fi -done - -# Check available open port for Gateway docs -DOCS_PORT=8080 -LIMIT=$((DOCS_PORT+1000)) -while [[ $DOCS_PORT -le LIMIT ]] - do - if [[ $(netstat -nat | grep "$DOCS_PORT") ]]; then - # check another port - ((DOCS_PORT = DOCS_PORT + 1)) - else - break - fi -done - -echo -echo "ℹ️ Confirm below if the instance and its folders are correct:" -echo - -printf "%30s %5s\n" "Gateway instance name:" "$INSTANCE_NAME" -printf "%30s %5s\n" "Version:" "hummingbot/gateway:$GATEWAY_TAG" -echo -printf "%30s %5s\n" "Hummingbot instance ID:" "$HUMMINGBOT_INSTANCE_ID" -printf "%30s %5s\n" "Gateway conf path:" "$CONF_FOLDER" -printf "%30s %5s\n" "Gateway log path:" "$LOGS_FOLDER" -printf "%30s %5s\n" "Gateway certs path:" "$CERTS_FOLDER" -printf "%30s %5s\n" "Gateway port:" "$GATEWAY_PORT" -printf "%30s %5s\n" "Gateway docs port:" "$DOCS_PORT" -echo - -prompt_existing_certs_path () { - echo - read -p "Enter the path to the folder where Hummingbot certificates are stored >>> " CERTS_PATH_TO_COPY - if [ "$CERTS_PATH_TO_COPY" == "" ] - then - echo - echo "After installation, set certificatePath in $CONF_FOLDER/server.yml and restart Gateway" - else - # Check if source folder exists - if [ ! -d "$CERTS_PATH_TO_COPY" ]; then - echo "Error: $CERTS_PATH_TO_COPY does not exist or is not a directory" - exit 1 - fi - # Copy all files in the source folder to the destination folder - cp -r $CERTS_PATH_TO_COPY/* $CERTS_FOLDER/ - # Confirm that the files were copied - if [ $? -eq 0 ]; then - echo "Files successfully copied from $CERTS_PATH_TO_COPY to $CERTS_FOLDER" - else - echo "Error copying files from $CERTS_PATH_TO_COPY to $CERTS_FOLDER" - exit 1 - fi - fi -} - -prompt_proceed () { - echo - read -p "Do you want to proceed with installation? [Y/N] >>> " PROCEED - if [ "$PROCEED" == "" ] - then - prompt_proceed - else - if [[ "$PROCEED" != "Y" && "$PROCEED" != "y" ]] - then - PROCEED="N" - fi - fi -} - -# Execute docker commands -create_instance () { - echo - echo "Creating Gateway instance ... " - echo - # 1) Create main folder for your new instance - mkdir $FOLDER - # 2) Create subfolders for gateway files - mkdir $CONF_FOLDER - mkdir $LOGS_FOLDER - mkdir $CERTS_FOLDER - # 3) Set required permissions to save gateway passphrase the first time - sudo chmod a+rw $CONF_FOLDER $CERTS_FOLDER - prompt_existing_certs_path - - # Launch a new instance of gateway - docker run \ - --name $INSTANCE_NAME \ - -p $GATEWAY_PORT:15888 \ - -p $DOCS_PORT:8080 \ - -v $CONF_FOLDER:/usr/src/app/conf \ - -v $LOGS_FOLDER:/usr/src/app/logs \ - -v $CERTS_FOLDER:/usr/src/app/certs \ - -e GATEWAY_PASSPHRASE="$PASSPHRASE" \ - hummingbot/gateway:$GATEWAY_TAG -} -prompt_proceed -if [[ "$PROCEED" == "Y" || "$PROCEED" == "y" ]] -then - create_instance -else - echo "Aborted" - echo -fi