-
Notifications
You must be signed in to change notification settings - Fork 18
Home
Apollo is a Discord bot for the University of Warwick Computing Society. It is designed to augment our Discord server with a few of the user services available on our website.
Apollo uses pipenv
for dependency and venv management. Install it with pip install pipenv
, and then run pipenv install
to install all the required dependencies into a new virtual environment.
-
pipenv install
, as above - Copy
config.example.yaml
toconfig.yaml
and configure the fields. - Copy
alembic.example.ini
toalembic.ini
and configure any fields you wish to change. - Set up the database by running migrations with
alembic upgrade head
.- The default database location is
postgresql://apollo:apollo@localhost/apollo
(inconfig.example.yaml
) This requires PostgreSQL to be installed, with a database calledapollo
and a user with name and passwordapollo
with access to it. - For testing purposes, you may wish to change it to a locally stored file such as
sqlite:///apollo.sqlite3
. - Alternatively, see the instructions below for using Docker.
- The default database location is
- On the Discord Developer Portal, make sure that your bot has the required intents.
- Currently, the Messages and Members intents are necessary.
Run Apollo using pipenv run python apollo.py
A Dockerfile and docker-compose are provided for easily running Apollo. Assuming you already have docker installed, run docker compose up
to start both Apollo and a postgres database.
The compose file uses a docker compose config to mount config.yaml
into the container at runtime, not at build time. Copy config.example.yaml
to config.yaml
and configure the fields so that compose can do this. You will need to change the database url to postgresql://apollo:apollo@apollo-db/apollo
if you wish to connect to the containerised database.
The docker image builds alembic.ini
into it by copying the example, as it is rare any values in this wish to be changed on a per-deployment basis.
When you first create the database container, you'll need to apply migrations:
- Run
docker compose up
to start both services. The python one won't work, but leave it running.- When changing any source files, the container will have to be rebuilt:
docker compose up --build
- When changing any source files, the container will have to be rebuilt:
- Run
docker compose exec apollo alembic upgrade head
to apply the database migrations. - Run
docker compose restart apollo
to restart the bot with migrations applied.
Migrations will need to be re-applied every time the database schema changes.