broker docs

This commit is contained in:
Michael Feng
2023-04-06 11:56:09 -07:00
parent 53be3bb6b0
commit 3e4593f850
6 changed files with 271 additions and 102 deletions

View File

@@ -29,7 +29,7 @@ If you are using a Mac with an Intel (x86) chipset, Windows or any other Intel-b
## Getting Started ## Getting Started
If you have installed Docker Compose successfully, the `docker-compose` command should be available in Terminal/Bash: In Terminal/Bash, run the following command to check that you have installed Docker Compose successfully:
``` ```
docker-compose docker-compose
``` ```
@@ -92,7 +92,7 @@ See [`conf_pure_mm_1.yml`](./hummingbot_files/conf/strategies/conf_pure_mm_1.yml
Now, use an IDE like [VSCode](https://code.visualstudio.com/) to edit the `docker-compose.yml` file. Now, use an IDE like [VSCode](https://code.visualstudio.com/) to edit the `docker-compose.yml` file.
We'll edit the section that defines the `CONFIG_PASSWORD` and `CONFIG_FILE_NAME` environment variables: Edit the section that defines the `CONFIG_PASSWORD` and `CONFIG_FILE_NAME` environment variables:
```yaml ```yaml
# environment: # environment:
# - CONFIG_PASSWORD=[password] # - CONFIG_PASSWORD=[password]
@@ -100,7 +100,7 @@ We'll edit the section that defines the `CONFIG_PASSWORD` and `CONFIG_FILE_NAME`
# - CONFIG_FILE_NAME=conf_pure_mm_1.yml # - CONFIG_FILE_NAME=conf_pure_mm_1.yml
``` ```
Remove the '#' to uncomment out: Uncomment out:
* The `environment:` line * The `environment:` line
* The `CONFIG_PASSWORD` line: add the password you set earlier, * The `CONFIG_PASSWORD` line: add the password you set earlier,
* One of `CONFIG_FILE_NAME` lines: add your script OR strategy config file * One of `CONFIG_FILE_NAME` lines: add your script OR strategy config file
@@ -117,7 +117,7 @@ Afterwards, save the file.
### 4. Launch network ### 4. Launch network
Now, the script or strategy will auto-start when you restart the Compose network Now, the script or strategy will auto-start when you restart the Compose project
``` ```
docker-compose up -d docker-compose up -d
``` ```
@@ -130,19 +130,19 @@ docker attach autostart_hummingbot_compose-bot-1
## Useful Docker Commands ## Useful Docker Commands
Use the commands below or use the Docker Desktop application to manage your Hummingbot container: Use the commands below or use the Docker Desktop application to manage your containers:
### Create/launch Compose network ### Create/launch Compose project
``` ```
docker-compose up -d docker-compose up -d
``` ```
### Remove the Compose network ### Remove the Compose project
``` ```
docker-compose down docker-compose down
``` ```
### Update the Compose network for the latest images ### Update the Compose project for the latest images
``` ```
docker-compose up --force-recreate --build -d docker-compose up --force-recreate --build -d
``` ```

View File

@@ -1,62 +1,220 @@
# Deploy: Hummingbot + Gateway (DEX Connectors) + EMQX Message Broker (MQTT feature) # Deploy Hummingbot + Gateway + Broker Instances
This docker compose deployment includes Gateway and EMQX broker. Though it is This installs a [Hummingbot](https://github.com/hummingbot/hummingbot) instance linked to a [Hummingbot Gateway](https://github.com/hummingbot/gateway) instance, along with an EMQX [Broker](https://github.com/hummingbot/brokers).
recommended to use the standalone deployments for message brokers from the [hummingbot/brokers](https://github.com/hummingbot/brokers)
repository. !!! note "Experimental deployment"
This deployment is still undergoing testing, so we recommend using the standalone deployments for message brokers from the [hummingbot/brokers](https://github.com/hummingbot/brokers) repository.
## Prerequisites
This configuration requires [Docker Compose](https://docs.docker.com/compose/), a tool for defining and running multi-container Docker applications. The recommended way to get Docker Compose is to install [Docker Desktop](https://www.docker.com/products/docker-desktop/), which includes Docker Compose along with Docker Engine and Docker CLI which are Compose prerequisites.
Docker Desktop is available on:
* [Linux](https://docs.docker.com/desktop/install/linux-install/)
* [Mac](https://docs.docker.com/desktop/install/mac-install/)
* [Windows](https://docs.docker.com/desktop/install/windows-install/)
## Apple M1/M2 and other ARM machines
If you have a recent Mac that uses Apple Silicon (M1/M2) chipset or another ARM-based machine, you need to change the image tag to ensure that you pull a container that is optimized for your chip architecture.
Use an IDE like [VSCode](https://code.visualstudio.com/) to edit the `docker-compose.yml` file. Change the tag for **both** the Hummingbot and Gateway images from `latest` to `latest-arm` to pull the images built for ARM-based machines.
You can also comment out the each line that contains `latest` and uncomment each line that contains `latest-arm`:
```
# image: hummingbot/hummingbot:latest
image: hummingbot/hummingbot:latest-arm
# image: hummingbot/gateway:latest
image: hummingbot/gateway:latest-arm
```
Afterwards, save the file and proceed to the next step.
If you are using a Mac with an Intel (x86) chipset, Windows or any other Intel-based machine, you don't need to make any changes before deploying a container.
## Getting Started
In Terminal/Bash, run the following command to check that you have installed Docker Compose successfully:
```
docker-compose
```
You should see a response that start with:
```
Usage: docker compose [OPTIONS] COMMAND
```
Clone this repo or copy the `docker-compose.yml` file to a directory on your machine where you want to store your Hummingbot files. This is where your encrypted keys, scripts, trades, configs, logs, and other files related to your bots will be saved.
To link the Hummingbot and Gateway instances, you first have to generate certificates within Hummingbot and set the `GATEWAY_PASSPHRASE` variable in the YAML file.
### 1. Generate certificates
Pull the latest Hummingbot and Gateway images and start instances with the following command:
```
docker-compose up -d
```
After the images have been downloaded, you should see the following output:
```
[+] Running 4/4
⠿ Network hummingbot_gateway_broker_compose_default Created
⠿ Container hummingbot_gateway_broker_compose-gateway-1 Started
⠿ Container hummingbot_gateway_broker_compose-emqx-1 Started
⠿ Container hummingbot_gateway_broker_compose-bot-1 Started
```
Attach to the Hummingbot `bot` instance:
```
docker attach hummingbot_gateway_broker_compose-bot-1
```
You should see the Hummingbot welcome screen:
![welcome screen](../welcome.png)
Set your Hummingbot [password](https://docs.hummingbot.org/operation/password/) and write it down. This is the `CONFIG_PASSWORD` environment variable in your `docker-compose.yml` file.
Afterwards, run the following command to generate Gateway certificates:
```
gateway generate-certs
```
You'll be prompted for a passphrase used to generate the certificates. This is the `GATEWAY_PASSPHRASE` environment variable in your `docker-compose.yml` file.
Afterwards, Hummingbot will use the passphrase to generate the certificates and save them in the `hummingbot_files/certs` folder, where the Gateway instance will look for the certificates it needs.
Now, run `exit` to exit the client.
### 2. Remove network
Once you're back in Bash/Terminal, run the following command to remove the Compose project:
```
docker-compose down
```
You should see the following output:
```
⠿ Container hummingbot_gateway_broker_compose-gateway-1 Removed
⠿ Container hummingbot_gateway_broker_compose-emqx-1 Removed
⠿ Container hummingbot_gateway_broker_compose-bot-1 Removed
⠿ Network hummingbot_gateway_broker_compose_default Removed
```
### 3. Modify YAML file
Now, use an IDE like [VSCode](https://code.visualstudio.com/) to edit the `docker-compose.yml` file.
Edit the section that defines the `CONFIG_PASSWORD` and `CONFIG_FILE_NAME` environment variables:
```yaml
bot:
# environment:
# - CONFIG_PASSWORD=[password]
gateway:
# environment:
# - GATEWAY_PASSPHRASE=[passphrase]
```
Uncomment out:
* The `environment:` lines
* The `CONFIG_PASSWORD` lines: add your Hummingbot password
* The `GATEWAY_PASSPHRASE` line: add the passphrase you used to generate the certificates
The final `environment` section of the YAML file should look like this:
```yaml
bot:
environment:
- CONFIG_PASSWORD=[password]
gateway:
environment:
- GATEWAY_PASSPHRASE=[passphrase]
```
Afterwards, save the file.
### 4. Recreate network
Now, recreate the Compose project:
```
docker-compose up -d
```
Attach to the Hummingbot `bot` instance:
```
docker attach hummingbot_gateway_broker_compose-bot-1
```
After you enter your password, you should now see `GATEWAY:ONLINE` in the upper-right hand corner.
Open a new Terminal/Bash window. In it, attach to the Gateway `gateway` instance to see its logs:
```
docker attach hummingbot_gateway_compose-gateway-1
```
### 5. Configure EMQX Broker
Attach to the EMQX Broker `emqx` instance:
```
docker attach hummingbot_gateway_broker_compose-emqx-1
```
After deploying for the first time, you can navigate to the EMQX dashboard to configure authentication and available ports at http://localhost:18083/.
After deploying for the first time, you can navigate to the EMQX dashboard
to configure authentication and available ports at http://localhost:18083/.
The default credentials for connecting to the dashboards are `admin:public`. The default credentials for connecting to the dashboards are `admin:public`.
For connecting your bots via MQTT, just leave the `mqtt_username` and
`mqtt_password` parameters of the bot empty.
## How to use it For connecting your bots via MQTT, just leave the `mqtt_username` and `mqtt_password` parameters of the bot empty.
You will need to have the certificates for the gateway and hummingbot under the folder hummingbot_files/certs. If you don't have it, don't worry, you can generate them with the client by doing the following: ## Useful Docker Commands
- Make sure you have docker and docker-compose installed. Use the commands below or use the Docker Desktop application to manage your containers:
- Run the following command in the terminal:
``` ### Create/Launch Compose project
docker-compose up -d ```
``` docker-compose up -d
```
- You will see that the gateway failed to start because you don't have the certificates ### Remove the Compose project
- Attach the instance of the bot by running: ```
docker-compose down
```
``` ### Update the Compose project for the latest images
docker attach hummingbot_gateway_compose-bot-1 ```
``` docker-compose up --force-recreate --build -d
```
- Create the password ### Attach to the Hummingbot container
- Run the following command in the client: ```
docker attach hummingbot_gateway_broker_compose-bot-1
```
``` ### Attach to the Gateway container
gateway generate-certs ```
``` docker attach hummingbot_gateway_compose-gateway-1
```
- When prompted enter the passphrase that you want. Is important that you change the docker-compose.yml on line 18 to the passphrase that you entered (the current passphrase is `a`). ### Attach to the EMQX Broker container
- Exit the client and run the following command in the terminal: ```
docker attach hummingbot_gateway_broker_compose-emqx-1
```
``` ### Detach from the container and return to command line
docker-compose down
```
- You will see that inside the hummingbot_files/certs folder you have the certificates. * Press keys <kbd>Ctrl</kbd> + <kbd>P</kbd> then <kbd>Ctrl</kbd> + <kbd>Q</kbd>
- We are ready to deploy the gateway and hummingbot, run the following command in the terminal:
``` ### List all containers
docker-compose up -d ```
``` docker ps -a
```
- If you attach the terminal of the gateway you will see that it is running. ### Stop a container
``` ```
docker attach hummingbot_gateway_compose-gateway-1 docker stop <instance-name>
``` ```
- If you attach the terminal of the bot you will see that it is running and the gateway is ONLINE. ### Remove a container
```
``` docker rm <instance-name>
docker attach hummingbot_gateway_compose-bot-1 ```
```

View File

@@ -2,6 +2,7 @@ version: "3.9"
services: services:
bot: bot:
image: hummingbot/hummingbot:latest image: hummingbot/hummingbot:latest
# image: hummingbot/hummingbot:latest-arm
volumes: volumes:
- "./hummingbot_files/conf:/conf" - "./hummingbot_files/conf:/conf"
- "./hummingbot_files/conf/connectors:/conf/connectors" - "./hummingbot_files/conf/connectors:/conf/connectors"
@@ -21,6 +22,7 @@ services:
gateway: gateway:
image: hummingbot/gateway:latest image: hummingbot/gateway:latest
# image: hummingbot/gateway:latest-arm
ports: ports:
- "15888:15888" - "15888:15888"
- "8080:8080" - "8080:8080"
@@ -28,8 +30,8 @@ services:
- "./gateway_files/conf:/usr/src/app/conf" - "./gateway_files/conf:/usr/src/app/conf"
- "./gateway_files/logs:/usr/src/app/logs" - "./gateway_files/logs:/usr/src/app/logs"
- "./hummingbot_files/certs:/usr/src/app/certs" - "./hummingbot_files/certs:/usr/src/app/certs"
environment: # environment:
- GATEWAY_PASSPHRASE=a # - GATEWAY_PASSPHRASE=[passphrase]
emqx: emqx:
image: emqx:5 image: emqx:5

View File

@@ -34,7 +34,7 @@ If you are using a Mac with an Intel (x86) chipset, Windows or any other Intel-b
## Getting Started ## Getting Started
If you have installed Docker Compose successfully, the `docker-compose` command should be available in Terminal/Bash: In Terminal/Bash, run the following command to check that you have installed Docker Compose successfully:
``` ```
docker-compose docker-compose
``` ```
@@ -63,7 +63,7 @@ After the images have been downloaded, you should see the following output:
⠿ Container hummingbot_gateway_compose-gateway-1 Started ⠿ Container hummingbot_gateway_compose-gateway-1 Started
``` ```
Attach to the Hummingbot instance: Attach to the Hummingbot `bot` instance:
``` ```
docker attach hummingbot_gateway_compose-bot-1 docker attach hummingbot_gateway_compose-bot-1
``` ```
@@ -72,7 +72,7 @@ You should see the Hummingbot welcome screen:
![welcome screen](../welcome.png) ![welcome screen](../welcome.png)
Set your [password](https://docs.hummingbot.org/operation/password/), which will be used to encrypt any keys you store with Hummingbot. Set your Hummingbot [password](https://docs.hummingbot.org/operation/password/) and write it down. This is the `CONFIG_PASSWORD` environment variable in your `docker-compose.yml` file.
Afterwards, run the following command to generate Gateway certificates: Afterwards, run the following command to generate Gateway certificates:
``` ```
@@ -87,7 +87,7 @@ Now, run `exit` to exit the client.
### 2. Remove network ### 2. Remove network
Once you're back in Bash/Terminal, run the following command to remove the Compose network: Once you're back in Bash/Terminal, run the following command to remove the Compose project:
``` ```
docker-compose down docker-compose down
``` ```
@@ -103,18 +103,27 @@ You should see the following output:
Now, use an IDE like [VSCode](https://code.visualstudio.com/) to edit the `docker-compose.yml` file. Now, use an IDE like [VSCode](https://code.visualstudio.com/) to edit the `docker-compose.yml` file.
We'll edit the section that defines the Gateway environment variables: Edit the section that defines the `CONFIG_PASSWORD` and `CONFIG_FILE_NAME` environment variables:
```yaml ```yaml
bot:
# environment: # environment:
# - GATEWAY_PASSPHRASE=[passphrase] # - CONFIG_PASSWORD=[password]
gateway:
# environment:
# - GATEWAY_PASSPHRASE=[passphrase]
``` ```
Remove the '#' to uncomment out: Uncomment out:
* The `environment:` line * The `environment:` lines
* The `CONFIG_PASSWORD` lines: add your Hummingbot password
* The `GATEWAY_PASSPHRASE` line: add the passphrase you used to generate the certificates * The `GATEWAY_PASSPHRASE` line: add the passphrase you used to generate the certificates
The final `environment` section of the YAML file should look like this: The final `environment` section of the YAML file should look like this:
```yaml ```yaml
bot:
environment:
- CONFIG_PASSWORD=[password]
gateway:
environment: environment:
- GATEWAY_PASSPHRASE=[passphrase] - GATEWAY_PASSPHRASE=[passphrase]
``` ```
@@ -123,18 +132,18 @@ Afterwards, save the file.
### 4. Recreate network ### 4. Recreate network
Now, recreate the Compose network: Now, recreate the Compose project:
``` ```
docker-compose up -d docker-compose up -d
``` ```
Attach to the Hummingbot instance: Attach to the Hummingbot `bot` instance:
``` ```
docker attach hummingbot_gateway_compose-bot-1 docker attach hummingbot_gateway_compose-bot-1
``` ```
After you enter your password, you should now see `GATEWAY:ONLINE` in the upper-right hand corner. After you enter your password, you should now see `GATEWAY:ONLINE` in the upper-right hand corner.
Open a new Terminal/Bash window. In it, attach to the Gateway instance to see its logs: Open a new Terminal/Bash window. In it, attach to the Gateway `gateway` instance to see its logs:
``` ```
docker attach hummingbot_gateway_compose-gateway-1 docker attach hummingbot_gateway_compose-gateway-1
``` ```
@@ -143,19 +152,19 @@ See [Gateway](https://docs.hummingbot.org/gateway/) for more details on how to c
## Useful Docker Commands ## Useful Docker Commands
Use the commands below or use the Docker Desktop application to manage your Hummingbot and Gateway container: Use the commands below or use the Docker Desktop application to manage your containers:
### Create/Launch Compose network ### Create/Launch Compose project
``` ```
docker-compose up -d docker-compose up -d
``` ```
### Remove the Compose network ### Remove the Compose project
``` ```
docker-compose down docker-compose down
``` ```
### Update the Compose network for the latest images ### Update the Compose project for the latest images
``` ```
docker-compose up --force-recreate --build -d docker-compose up --force-recreate --build -d
``` ```

View File

@@ -34,7 +34,7 @@ If you are using a Mac with an Intel (x86) chipset, Windows or any other Intel-b
## Getting Started ## Getting Started
If you have installed Docker Compose successfully, the `docker-compose` command should be available in Terminal/Bash: In Terminal/Bash, run the following command to check that you have installed Docker Compose successfully:
``` ```
docker-compose docker-compose
``` ```
@@ -88,7 +88,7 @@ Now, run `exit` to exit the client.
### 2. Remove network ### 2. Remove network
Once you're back in Bash/Terminal, run the following command to remove the Compose network: Once you're back in Bash/Terminal, run the following command to remove the Compose project:
``` ```
docker-compose down docker-compose down
``` ```
@@ -108,40 +108,40 @@ Now, use an IDE like [VSCode](https://code.visualstudio.com/) to edit the `docke
We'll edit the section that defines the following environment variables: We'll edit the section that defines the following environment variables:
```yaml ```yaml
bot: bot:
# environment: # environment:
# - CONFIG_PASSWORD=[password] # - CONFIG_PASSWORD=[password]
bot2: bot2:
# environment: # environment:
# - CONFIG_PASSWORD=[password] # - CONFIG_PASSWORD=[password]
gateway: gateway:
# environment: # environment:
# - GATEWAY_PASSPHRASE=[passphrase] # - GATEWAY_PASSPHRASE=[passphrase]
``` ```
Remove the '#' to uncomment out: Uncomment out:
* The two `environment:` lines * The `environment:` lines
* The `CONFIG_PASSWORD` line: add your Hummingbot password * The `CONFIG_PASSWORD` lines: add your Hummingbot password
* The `GATEWAY_PASSPHRASE` line: add the passphrase you used to generate the certificates * The `GATEWAY_PASSPHRASE` line: add the passphrase you used to generate the certificates
The final `environment` section of the YAML file should look like this: The final `environment` section of the YAML file should look like this:
```yaml ```yaml
bot: bot:
environment: environment:
- CONFIG_PASSWORD=[password] - CONFIG_PASSWORD=[password]
bot2: bot2:
environment: environment:
- CONFIG_PASSWORD=[password] - CONFIG_PASSWORD=[password]
gateway: gateway:
environment: environment:
- GATEWAY_PASSPHRASE=[passphrase] - GATEWAY_PASSPHRASE=[passphrase]
``` ```
Afterwards, save the file. Afterwards, save the file.
### 4. Recreate network ### 4. Recreate network
Now, recreate the Compose network: Now, recreate the Compose project:
``` ```
docker-compose up -d docker-compose up -d
``` ```
@@ -166,19 +166,19 @@ See [Gateway](https://docs.hummingbot.org/gateway/) for more details on how to c
## Useful Docker Commands ## Useful Docker Commands
Use the commands below or use the Docker Desktop application to manage your Hummingbot and Gateway container: Use the commands below or use the Docker Desktop application to manage your containers:
### Create/Launch Compose network ### Create/Launch Compose project
``` ```
docker-compose up -d docker-compose up -d
``` ```
### Remove the Compose network ### Remove the Compose project
``` ```
docker-compose down docker-compose down
``` ```
### Update the Compose network for the latest images ### Update the Compose project for the latest images
``` ```
docker-compose up --force-recreate --build -d docker-compose up --force-recreate --build -d
``` ```

View File

@@ -29,7 +29,7 @@ If you are using a Mac with an Intel (x86) chipset, Windows or any other Intel-b
## Getting Started ## Getting Started
If you have installed Docker Compose successfully, the `docker-compose` command should be available in Terminal/Bash: In Terminal/Bash, run the following command to check that you have installed Docker Compose successfully:
``` ```
docker-compose docker-compose
``` ```
@@ -69,19 +69,19 @@ To get started with Hummingbot, check out the following docs:
## Useful Docker Commands ## Useful Docker Commands
Use the commands below or use the Docker Desktop application to manage your Hummingbot container: Use the commands below or use the Docker Desktop application to manage your containers:
### Create the Compose network ### Create the Compose project
``` ```
docker-compose up -d docker-compose up -d
``` ```
### Stop the Compose network ### Stop the Compose project
``` ```
docker-compose down docker-compose down
``` ```
### Update the Compose network for the latest images ### Update the Compose project for the latest images
``` ```
docker-compose up --force-recreate --build -d docker-compose up --force-recreate --build -d
``` ```