generated from 0x5c/quick-bot-no-pain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d80d0c3
Showing
17 changed files
with
672 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/data/ | ||
/templates/data/ | ||
|
||
.github/ | ||
.git/ | ||
.gitignore | ||
|
||
/*env/ | ||
|
||
.flake8 | ||
|
||
docker-compose.y*ml | ||
|
||
Makefile | ||
|
||
README*.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# --- Custom --- | ||
|
||
|
||
# --- quick-bot-no-pain --- | ||
|
||
# Settings and keys | ||
data/options.py | ||
data/keys.py | ||
|
||
# Virtual environments | ||
botenv/ | ||
venv/ | ||
env/ | ||
|
||
# Editors & IDEs | ||
.vscode/ | ||
*.code-workspace | ||
|
||
# Python cache files | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# A minimal Dockerfile for painless discord bots. | ||
# v1.0.0 | ||
# Copyright (c) 2019 classabbyamp, 0x5c | ||
# Released under the terms of the MIT license. | ||
# Part of: | ||
# https://github.com/0x5c/quick-bot-no-pain | ||
|
||
|
||
FROM alpine:3.10 | ||
|
||
COPY . /app | ||
WORKDIR /app | ||
|
||
ENV PYTHON_BIN python3 | ||
|
||
RUN \ | ||
echo "**** install build packages ****" && \ | ||
apk add --no-cache --virtual=build-dependencies \ | ||
g++ \ | ||
git \ | ||
gcc \ | ||
libressl-dev \ | ||
python3-dev && \ | ||
echo "**** install runtime packages ****" && \ | ||
apk add --no-cache \ | ||
libressl \ | ||
py3-pip \ | ||
python3 && \ | ||
echo "**** install pip packages ****" && \ | ||
pip3 install -U pip setuptools wheel && \ | ||
pip3 install -r requirements.txt && \ | ||
echo "**** clean up ****" && \ | ||
apk del --purge \ | ||
build-dependencies && \ | ||
rm -rf \ | ||
/root/.cache \ | ||
/tmp/* \ | ||
/var/cache/apk/* | ||
|
||
CMD ["/bin/sh", "run.sh", "--pass-errors", "--no-botenv"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 0x5c | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# A quick installation script for painless discord bots. | ||
# v2.0.0 | ||
# Copyright (c) 2019 0x5c | ||
# Released under the terms of the MIT license. | ||
# Part of: | ||
# https://github.com/0x5c/quick-bot-no-pain | ||
|
||
|
||
.DEFAULT_GOAL := help | ||
|
||
### Variables ### | ||
# Those are the defaults; they can be over-ridden if specified | ||
# at en environment level or as 'make' arguments. | ||
BOTENV ?= botenv | ||
PYTHON_BIN ?= python3.7 | ||
PIP_OUTPUT ?= -q | ||
|
||
|
||
### Support targets ### | ||
|
||
.PHONY: help | ||
help: | ||
@echo "" | ||
@echo "\033[97m>>>>>> Default dummy target <<<<<<" | ||
@echo "\033[37mYou might want to specify a target:" | ||
@echo "\033[32m --> make install" | ||
@echo "\033[94m --> make clean" | ||
@echo "\033[0m" | ||
|
||
|
||
### Actual install/setup targets ### | ||
|
||
# Main install target | ||
.PHONY: install | ||
install: $(BOTENV)/req_done data/options.py data/keys.py | ||
|
||
# Virual environment setup | ||
$(BOTENV)/success: | ||
ifneq ("$(wildcard ./$(BOTENV).)",) | ||
@echo "\033[94m--> Creating the virtual environment...\033[0m" | ||
@$(PYTHON_BIN) -m venv $(BOTENV) | ||
@touch $(BOTENV)/success | ||
endif | ||
|
||
# Installing requirements | ||
$(BOTENV)/req_done: requirements.txt $(BOTENV)/success | ||
@echo "\033[34;1m--> Installing the dependencies...\033[0m" | ||
@. $(BOTENV)/bin/activate; \ | ||
pip install ${PIP_OUTPUT} -U pip setuptools wheel; \ | ||
pip install ${PIP_OUTPUT} -U -r requirements.txt | ||
@touch $(BOTENV)/req_done | ||
|
||
# Creating the ./data subdirectory | ||
data: | ||
@echo "\033[34;1m--> Creating ./data ...\033[0m" | ||
@mkdir -p data | ||
|
||
# Copying templates | ||
data/options.py data/keys.py: ./data | ||
@echo "\033[34;1m--> Copying template for ./$@ ...\033[0m" | ||
@cp -nv ./templates/$@ ./$@ | ||
@touch ./$@ | ||
|
||
# Deletes the python cache and the virtual environment | ||
.PHONY: clean | ||
clean: | ||
@echo "\033[34;1m--> Removing python cache files...\033[0m" | ||
rm -rf __pycache__ | ||
@echo "\033[34;1m--> Removing the virtual environment...\033[0m" | ||
rm -rf $(BOTENV) | ||
|
||
|
||
### Dev targets ### | ||
|
||
|
||
### Special targets ### | ||
.PHONY: onlyenv | ||
onlyenv: $(BOTENV)/success |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
# Docker help for {{bot}} | ||
|
||
You have multiple options to run an instance of {{bot}} using docker. | ||
|
||
- [Docker help for {{bot}}](#docker-help-for-bot) | ||
- [Using docker-compose and building the image](#using-docker-compose-and-building-the-image) | ||
- [Using pure docker](#using-pure-docker) | ||
- [[Optional] Building the image](#optional-building-the-image) | ||
- [Creating the container](#creating-the-container) | ||
|
||
|
||
<!-- !! ONLY include this part if you provide a prebuilt image !! | ||
## Using docker-compose and the prebuilt-image (recommended) | ||
This is the easiest method for running the bot without any modifications. | ||
**Do not clone the repository when using this method!** | ||
1. Create a new directory and `cd` into it. | ||
2. Create the `docker-compose.yml` file: | ||
```yaml | ||
version: '3' | ||
services: | ||
{{bot}}: | ||
image: "{{user}}/{{image}}:latest" | ||
restart: on-failure | ||
volumes: | ||
- "./data:/app/data:rw" | ||
environment: | ||
- PYTHONUNBUFFERED=1 | ||
``` | ||
3. Create a subdirectory named `data`. | ||
4. Copy the templates for `options.py` and `keys.py` to `data/`, and edit them. | ||
5. Run `docker-compose`: | ||
```none | ||
$ docker-compose pull | ||
$ docker-compose up -d | ||
``` | ||
> Run without "-d" to test the bot. (run in foreground) | ||
--> | ||
|
||
|
||
## Using docker-compose and building the image | ||
|
||
This is the easiest method to run the bot with modifications. | ||
|
||
1. `cd` into the repository. | ||
|
||
2. Create the `docker-compose.yml` file: | ||
|
||
```yaml | ||
version: '3' | ||
services: | ||
{{bot}}: | ||
build: . | ||
image: "{{image}}:local-latest" | ||
restart: on-failure | ||
volumes: | ||
- "./data:/app/data:rw" | ||
environment: | ||
- PYTHONUNBUFFERED=1 | ||
``` | ||
3. Create a subdirectory named `data`. | ||
|
||
4. Copy the templates for `options.py` and `keys.py` to `data/`, and edit them. | ||
|
||
5. Run `docker-compose`: | ||
|
||
```none | ||
$ docker-compose build --pull | ||
$ docker-compose -d | ||
``` | ||
|
||
> Run without "-d" to test the bot. (run in foreground) | ||
|
||
|
||
|
||
## Using pure docker | ||
|
||
This methods is not very nice to use. | ||
*I just wanna run the darn thing, not do gymnastics!* | ||
|
||
|
||
### [Optional] Building the image | ||
|
||
1. `cd` into the repository. | ||
|
||
2. Run docker build: | ||
|
||
```none | ||
$ docker build -t {{image}}:local-latest . | ||
``` | ||
|
||
|
||
### Creating the container | ||
|
||
1. Be in a directory with a `data/` subdirectory, which should contain valid `options.py` and `keys.py` files (copy and edit the templates). | ||
|
||
2. Run the container: | ||
|
||
```none | ||
$ docker run -d --rm --mount type=bind,src=$(pwd)/data,dst=/app/data --name {{bot}} [image] | ||
``` | ||
|
||
Where `[image]` is either of: | ||
- `{{image}}:local-latest` if you are building your own. | ||
<!-- !! ONLY include this part if you provide a prebuilt image !! | ||
- `{{user}}/{{image}}:latest` if you want to use the prebuilt image. | ||
--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# *Quick tools for painless Discord bots* | ||
*Don't let your bot development become that:* ![:coolcry:](./docs/coolcry.png) | ||
|
||
[![Discord](https://img.shields.io/discord/591099017492955166?color=%237289DA&label=Discord)](https://discordapp.com/invite/6reX7e) | ||
|
||
A collection of tools to aid in creating and using discord.py bots, painlessly. | ||
|
||
|
||
## Tools | ||
|
||
*Click on the tool names to skip to documentation:* | ||
|
||
- [Makefile](./docs/makefile.md) Setup script for venv and more | ||
|
||
- [run.sh](./docs/run.sh.md) Simple startup script that handles restarting/exiting the bot | ||
|
||
- [Skeleton files](./docs/skeleton.md) Minimal templates of important and often missed bot files | ||
|
||
- [Docker files](./docs/docker.md) Docker-related files | ||
|
||
|
||
> **Windows:** Usage of most of these on Windows is untested, but should not cause problems with mingw64, MSYS/2, and such. | ||
> Well... *probably.* | ||
|
||
## Repository template | ||
|
||
To use this repository as a base for your new bot, just use the *Template* feature of GitHub: | ||
![GitHub template button](./docs/github-templates.png) | ||
Feel free to remove any file you do not wish to use. | ||
|
||
|
||
## Changelog | ||
|
||
Changelogs for individual tools are in the tools' documentation files. | ||
|
||
- [2019-12-23] Added Docker files. | ||
- [2019-11-24] v2.0.0 - Stable snapshot - Moved option/keys to "./data". | ||
- [2019-10-06] Added `Makefile`, `run.sh`, and skeleton files. | ||
|
||
|
||
## License | ||
|
||
Copyright (c) 2019 0x5c | ||
|
||
This project is released under the MIT license. | ||
See `LICENSE` for the full license text. | ||
|
||
**Some parts** of this project are released under the terms of the Unlicense, | ||
and are identified as such in their documentation file. | ||
See the relevant documentation files for the full license text. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Quick bot, No pain / **Docker files** | ||
|
||
Minimal dockerfile and instructions for using it, [almost] ready to ship. | ||
|
||
|
||
## Included files | ||
|
||
| File | Description | | ||
| ------------------ | --------------------------------------------------------- | | ||
| `Dockerfile` | Minimal dockerfile for running your bot, uses `run.sh`. | | ||
| `README-DOCKER.md` | Template for instructions to run your bot through docker. | | ||
| `.dockerignore` | Docker ignore file. | | ||
|
||
|
||
## Usage | ||
|
||
### `Dockerfile` | ||
|
||
The dockerfile, as-is, should be ready to use for a bot with no additional dependencies. Modify it to fit the needs of your bot. | ||
|
||
Usage of the dockerfile itself is documented in `README-DOCKER.md`. | ||
|
||
> Publishing a prebuilt image on the Docker Hub is extensively documented elsewhere, and is outside the scope of these instructions. However, the required files are present in this repository. | ||
### `README-DOCKER.md` | ||
|
||
The instructions are provided as a fairly complete template. Remove or uncomment the commented blocks, and replace `{{bot}}`, `{{user}}`, and `{{image}}` with the appropriate values. | ||
|
||
### `.dockerignore` | ||
|
||
The dockerignore file is to be expanded with any new file/directory that should not be included in the image. | ||
|
||
> The dockerignore file serves as a way to excludes files and directories from the image. While commonly omitted from projects, it is best practice and helps lowering the building time and image size. | ||
|
||
## Changelog | ||
|
||
```md | ||
## [1.0.0] - 2019-12-23 | ||
### Added | ||
- Dokerfile | ||
- Docker instructions | ||
- dockerignore file | ||
``` |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.