Docker Voter - automatic, easy local install for Steem FOSSbot Voter!

in #bots7 years ago

Following on from @shaunmza 's excellent post detailing how Dockerize the Steem FOSSbot, I've simplified the set up with an installer and helper project called docker-voter.

It allows you to:

  1. Set up your Voter bot variables interactively from the command line (no manual file creation or editing required)
  2. Build, run and stop a Docker deployment of Voter bot
  3. Easily keep your Voter bot up to date with the latest version

You can do this anywhere where docker will run! For those of you who found the original Heroku deployment option troublesome, because of creating an account or limits on usage, this is for you. You can run this locally on your home computer.

Requirements

It is possible for something similar to work on Windows but this in not provided here. If you want to make a few batch files and test this on Windows, please get in touch.

Also note that a Raspberry Pi deployment is kind of complex because Docker will only run on ArchLinux for that. I'll probably write a tutorial for this at some stage but it's beyond the scope of this post.

Install instructions

Open a terminal, and type in the following:

git clone https://github.com/Steem-FOSSbot/voter-docker.git

cd voter-docker

run.sh script

The run.sh script handles everything you will need to do to set up and run the Docker deployment

Thanks to @someguy123, this script is based on his script for steem-docker.

Setup

Run the setup command as root (super user / admin) and follow the prompts

sudo ./run.sh setup

If there are existing setup files, you will be warned that this will reset any settings you have set in environment variables. But note that it will not delete you Voter algorithm and config variables if they exist.

If it's not the first time and you just want to update the Voter bot code to the latest, without destroying your settings, use sudo ./run.sh update instead and see the Update section below.

Prompts

You'll be asked for 5 settings:

  1. Cookie secret (something random you don't need to remember)
  2. Bot API key (use this to access the web app dashboard)
  3. Steem username
  4. Steem private posting key
  5. Frequency to run bot
    1. Daily
    2. Hourly
    3. Every 30 mins
    4. Every 10 mins
    5. Every 5 mins

After this you'll be asked if you want to build now. Accept this, or run ./run.sh build later.

Building the first time should take a while and there will be some downloading, so as @shuanmza said, get a cuppa tea! Rebuilding will take significantly less time if you update, under a minute for me.

Once built, you will not need to do anything up to this point again unless you want to update settings or the Voter bot code to latest version.

Running Voter bot

You can either run it normally or as a background process. This makes no difference to its operation, but will either block you terminal or not if background, so background is probably the better choice.

Normally

Run:

./run.sh start

That's it! If you're configuration was correct (the right username, post key) then the bot will be automatically running.

However you will need to create or import a bot algorithm if this is a first time set up. See below for more information.

To quit properly, use Ctrl+C which will cause Docker to shutdown nicely.

As background process

Run:

./run.sh bgstart

This will start Voter bot in Docker and free up the terminal.

To see the logs use ./run.sh logs

To stop this Docker deployment, use ./run.sh bgstop

Accessing the web app dashboard

When running, go to http://127.0.0.1:5000 in your web browser to access Docker.

From here, everything is identical to the dashboard usage instructions for Heroku or any other deployment.

If it's your first time running the bot you should check out the usage instruction also.

If you're migrating from Heroku, see section 6 "Export / Import configs and algorithms" in @shaunmza 's post on this.

And don't forget to refill your cup of tea!

BONUS! Access on your local network

Unless your you have a firewall blocking port 5000 on your local network, you'll be able to access the web app dashboard from a difference device using the local IP of the computer it is running on!

These will generally be in form of 192.168.0.xx, where xx is some number. If this is 24 for example, then you will go to http://192.168.0.24:5000 on the browser of a different computer.

This means it can act like a local server. If you firewall does block it you can always open that one port.

Updating, the easy way!

One of the big drawbacks with the Heroku deployment (besides the limited free usage and credit card details entry!) is the difficulty in updating the Voter code to the latest version when a new version is released.

New versions are released quite often at the moment because it's still in beta, and there are important bug fixes coming out pretty much weekly. So saying up to date is important.

To update, all you need to do is run as root

sudo ./run.sh update

After update, you will need to rebuild the Docker, but you will be prompted as in setup.

Performance

Docker works very well on my Mac, though it is resource hungry. I haven't tested on Linux but it should work fine.

I've found that if the Internet connection is interrupted or the computer is suspended / goes to sleep, Voter will pick up exactly where it left off and continue running when possible without restarting the Docker. This is a big plus for me.

Digital Ocean issue

@shaunmza mentioned in a comment on his article that he was getting Redis database disconnects after a few hours (> 10 hrs) when running on Digital Ocean. This issue is still ongoing and I'd expect a post from them when more is known.

However from my testing, local install works perfectly.

Technical notes

This deployment does not use the master branch of steem-fossbot-voter, it uses its own branch called docker-release. This is because there are a few extra files required for Docker that I decided to keep out of the main work branches.

These files are the 3 template files from the original tutorial, and a helper script that is actually called as part of the ./run.sh setup flow.

This was to get around the problem of versioning two separate projects with different config files. Essentially the Voter bot can actually be run without voter-docker, but it will not have a Redis database nor have its environment variables correct set up.

Thanks!

Thanks again to @shaunmza for doing the work to figure this out. I've just made it a bit easier to get going so hopefully it makes it more accessible for people.

If you're confused about getting git or using the terminal, you can always ask us on the bots channel on steemit.chat

Enjoy! 😄 🤓 🤡

Sort:  

Your reward for being in Promoted is an upvote from @pipes.

Thank you for voting me out of the dregs on my first day. Appreciated. Upvoted and Followed.

Excellent work, this made the setup way easier!

I also like the easy updating, previously you would have needed to pull branches, merge etc. Then rebuild your containers after that, this is much simpler.

Thanks, super happy with it. 😆 Now if someone just wants to do a Windows batch script... 😉

Coin Marketplace

STEEM 0.14
TRX 0.12
JST 0.025
BTC 54114.77
ETH 2331.62
USDT 1.00
SBD 2.13