๐ณRunning in Docker
Bot Docker Setup
To run the bot in a containerized environment the repository provides a simple Dockerfile
. It is possible to spin up containers one by one by using this docker file and chaning the .env
file, however, it is also possible to spin up multiple instances of the bot using docker-compose
mechanic from docker and the provided docker-compose.yml
file (advised). Both of the options use the Dockerfile
from the repository.
First off, make sure that Docker is correctly installed:
The Dockerfile
currently holds commands to start the index.ts
file and install the required packages:
Docker Run method
This specific section describes how to run a single instance of the bot in a containerized environment. It utilizes the Dockerfile
and requires a few manual operations. If you plan on spinning up multiple instance of the bot, it might be easier to use the docker-compose
method.
Creating Image
The first step in running the bot in a Docker Container is to create the image
, to do so, run in the root folder of the repository:
Make sure to replace [name you want]
with whatever name you would like for the image.
Note: the images will use the environment variable described in .env
, you have to change these before creating the image.
When the image is succesfully created you can view it with:
Make sure the image you just created is listed in the above result of the docker image
command.
Starting the Container
To start the previously created image in a Docker Container:
Again, make sure to replace [name of your image]
with the name of the previously created image. The --restart=always
flag will make sure the bot will restart on an error. For example when we encounter a timeout by a RPC_ENDPOINT, the bot will restart and continue running. In our case the command would be:
The output will be the same as starting the bot with npm start
. After executing the run
command you will continue to see the logs in console, which you can safely close without the bot shutting down. To view all running containers:
Docker Compose method
If you plan on running multiple instances of the bot that use different .env
files, it might be more suitable to use the docker-compose
method. This is supported by the provided docker-compose.yml
file in the repository that has to be altered to your needs. For example when spinning up two containers, one for terra and one for juno, using the terra.env
and the juno.env
respectively, the file looks like this:
Now to build an run both instances (services) we simply hit:
and the containers should be running on completion, to check, hit:
Last updated