Skip to content

Instantly share code, notes, and snippets.

@LeoVerto
Last active March 12, 2017 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LeoVerto/58b89110ee8e591a1532e50761f5d625 to your computer and use it in GitHub Desktop.
Save LeoVerto/58b89110ee8e591a1532e50761f5d625 to your computer and use it in GitHub Desktop.

Creating a complete botbot development environment using Docker containers

Botbot is a strange piece of software, it consists of three different repositories and uses at least three different programming languages (namely Python, Go and JS).

For basic plugin development using botbot-shell if often sufficient but as soon as you want to do some manual integration testing or work on botbot-web you're going to need a full dev environment.

The goal of this guide is to walk you through setting up a complete botbot setup that I would not exactly recommend for production but should be fine for development and testing.

Disclaimer: This guide assumes you won't want to work on botbot-bot as we haven't forked that yet but go should allow for installing packages from local sources the same way pip does.

This guide is based on the official installation guide.

Prerequisites

  • Python 2
  • Go
  • Docker
  • virtualenv
  • postgresql (we need pg_config)
  • Some IRC server, could be something like freenode or your own (I use a docker one)

Cloning & Dependencies

Clone https://github.com/metabrainz/botbot-web:
git clone git@github.com:metabrainz/botbot-web.git

Clone https://github.com/metabrainz/botbot-plugins:
git clone git@github.com:metabrainz/botbot-plugins.git

Create a virtualenv and activate it:
virtualenv -p python2 venv
source venv/bin/activate
or if you're using virtualenvwrapper:
mkvirtualenv -p python2 botbot
workon botbot

Run botbot-web's makefile, this will take quite a while:
make dependencies

Docker

While this is running, let's continue by setting up our docker containers, pull redis and postgres:
docker pull redis
docker pull postgres

And start them:
docker run --name botbot-redis -p 127.0.0.1:6379:6379 -d redis
docker run --name botbot-postgres -e POSTGRES_PASSWORD=botbotpasswd -p 127.0.0.1:5432:5432 -d postgres

The official guide has some additional steps for database setup so we'll run them on the postgres container:
docker exec botbot-postgres createdb -U postgres botbot
docker exec botbot-postgres psql -U postgres -c "create extension hstore"

.env

Now back to botbot-web, first cd into its directory:
cd botbot-web

Now copy .env.example to .env and change the line
STORAGE_URL=postgres://user:pass@localhost:5432/botbot
to
STORAGE_URL=postgres://postgres:botbotpasswd@localhost:5432/botbot

Now activate the env:
export $(cat .env | grep -v ^# | xargs)
You'll only have to do this during the installation, honcho should handle it in the future.

Final steps

If you're lucky and botbot-web is done installing the dependencies, you can now continue.

Seeing as we're going to work from a local clone of botbot-plugins, uninstall the current one and tell pip to use the repo instead:
pip uninstall botbot-plugins
pip install -e /path/to/botbot-plugins

For some reason Procfile assumes manage.py is in $PATH so you'll have to replace manage.py in Procfile with ./manage.py.

Before you can run botbot, you need to set up the database for it by running:
./manage.py migrate

Then create an admin account:
./manage.py createsuperuser

Now you can start the server using honcho start.

You should now have a running botbot installation! However if you're testing your bot, please create a testing channel for that and do not do that in #metabrainz.

Tips and Tricks

You can start modules seperately using honcho start <module>.
E.g. to be able to keep bot and web running while working on plugins, run honcho start bot web in one terminal and honcho start plugins in another.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment