From 9ecf4f2fd2aa5044a32509010da534dd0f3bcb4d Mon Sep 17 00:00:00 2001 From: Ian Burgwin Date: Wed, 25 Nov 2020 11:53:53 -0800 Subject: [PATCH] update README for local testing and current maintainer info, add docker-compose.yml for local testing, update local image name, ignore yml files for image build --- .dockerignore | 2 +- README.md | 76 +++++++++++++++++++++++++++++++++++++++++++--- docker-compose.yml | 3 +- dockerbuild.sh | 2 +- 4 files changed, 75 insertions(+), 8 deletions(-) diff --git a/.dockerignore b/.dockerignore index a668c61b6..6d280cfde 100644 --- a/.dockerignore +++ b/.dockerignore @@ -3,8 +3,8 @@ kurisudb .git .github .gitignore -.travis.yml .dockerignore +*.yml Dockerfile token.txt config.ini diff --git a/README.md b/README.md index 54f7f5136..ac065b0f7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,75 @@ # Kurisu -A Discord server bot started by 916253 and primarily written by ihaveamac/ihaveahax. Designed heavily around the [Nintendo Homebrew Discord](https://discord.gg/C29hYvh). + +A Discord server bot developed for [Nintendo Homebrew on Discord](https://discord.gg/C29hYvh). Originally created by 916253, later updated by ihaveahax, and now is maintained primarily by NH staff and helpers. Although it is open source, this bot is not really designed to be used in other setups at the moment; the source is mainly just available for those interested in how it works on the Nintendo Homebrew server. -## Requirements: -* Python 3.8 or above -* Postgresql Server 13.0 or above -* Everything in requirements.txt +## Server template + +A server template is available for testing Kurisu, with all the channels and roles necessary. + +* https://discord.new/gJjzKQWCtJUx + +## Setting up for local testing in Docker (recommended) + +To test changes to Kurisu locally using Docker, make sure Docker Desktop (Windows and macOS) or Docker Engine (Linux) is installed. + +* [Get Docker | Docker Documentation](https://docs.docker.com/get-docker/) + +For Linux, docker-compose must be installed separately. + +* [Install Docker Compose | Docker Documentation](https://docs.docker.com/compose/install/) + +Create a new application on Discord and add a bot. Put the token in `token.txt` in the same directory. (Newline at the end of the file doesn't matter.) + +* [Discord Developer Portal](https://discord.com/developers/applications) + +Start Kurisu with the following command. Assuming a clean setup, this will pull postgres:13 to run as the database, and python:3.8-slim-buster as the base image for Kurisu, then build a new Kurisu image. Then it will start up postgres first, then kurisu once the database is active. + +``` +docker-compose up --build +``` + +postgres database files are stored in `./kurisudb`. Use Ctrl-C if not running in detached mode to stop the bot. + +### Other useful commands + +* `docker-compose build` - Build only, pull base images if required + +* `docker-compose build --pull` - Build only, always try to pull base images for newer versions + +* `docker-compose pull` - Pull images, in this case update postgres:13 + +* `docker-compose up -d` - Detach and run containers in the background + +* `docker-compose down` - Stop running containers and remove them + +## Set up for local testing manually + +* Ever since the move to Docker and PostgreSQL this has not been as well tested, so tell us if something is wrong or confusing! + +Set up PostgreSQL 13 or later (older versions aren't tested but might work). + +Python 3.8 or later is required. + +Install the dependencies in `requirements.txt`, ideally in a virtual environment. + +Create a new application on Discord and add a bot. + +- [Discord Developer Portal](https://discord.com/developers/applications) + +Inside `data/`, create `config.ini` with the contents: + +```ini +[Main] +token = +database_url = +``` + +`database_url` should follow a format like `postgresql://user:password@ipaddr/database` (example: `postgresql://kurisu:dev123@127.0.0.1/kurisu`). + +Run the bot: + +``` +python3 kurisu.py +``` diff --git a/docker-compose.yml b/docker-compose.yml index 5b6208d36..da5d148ad 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,7 +15,8 @@ services: restart: always kurisu: - image: ghcr.io/nh-server/kurisu + build: . + image: kurisutest environment: KURISU_TOKEN_FILE: /run/secrets/kurisu_token DB_USER: kurisu diff --git a/dockerbuild.sh b/dockerbuild.sh index c83a0bab4..3612e6edb 100755 --- a/dockerbuild.sh +++ b/dockerbuild.sh @@ -1,2 +1,2 @@ #!/bin/sh -docker build --build-arg COMMIT=$(git rev-parse HEAD) --build-arg BRANCH=$(git rev-parse --symbolic-full-name HEAD) -t ghcr.io/nh-server/kurisu . +docker build --build-arg COMMIT=$(git rev-parse HEAD) --build-arg BRANCH=$(git rev-parse --symbolic-full-name HEAD) -t kurisutest .