TLG_JoinCaptchaBot/docker/README.md

71 wiersze
2.2 KiB
Markdown

2019-08-06 01:47:13 +00:00
# Docker configuration
This document lists the requirements and steps to run
[TLG_JoinCaptchaBot](https://github.com/J-Rios/TLG_JoinCaptchaBot) in a docker
container.
## Pre-requisites
* [docker](https://www.docker.com/products/docker-engine). If possible, install
it using your OS native packaging system (under Debian based systems, use
`apt-get install docker-ce`).
* GNU Make, which should be installed on most Linux distributions by default.
## Building a new image
Create a new bot on Telegram using [The BotFather](http://t.me/BotFather). Make
sure your bot can be invited to groups and has privacy set to _disabled_.
Without this, the bot won't be able to read messages on the group.
2019-08-06 01:47:13 +00:00
Save the bot token. The token _should not publicly visible_ as anyone with it
could take control of your bot instance. We'll use the token to create the
2019-08-06 01:47:13 +00:00
docker image containing the bot (below).
Create the docker image:
2019-08-06 01:47:13 +00:00
```bash
make
2019-08-06 01:47:13 +00:00
```
The build process may take a while, depending on your computer and connection
speeds. Docker will indicate a successful build at the end of the process with
something like:
```bash
2019-08-06 01:47:13 +00:00
Successfully built (number)
Successfully tagged captcha-bot:latest
```
## Running
To run an instance, use the next command placing your Bot token to pass it as
an enviroment variable:
2019-08-06 01:47:13 +00:00
```bash
docker run -d --name captcha-bot --env CAPTCHABOT_TOKEN="XXXXXXXXX:XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" --restart always captcha-bot
2019-08-06 01:47:13 +00:00
```
This will start the container in the background. Use `docker ps` to check if
the container is up and running, and `docker logs captcha-bot` to
investigate the logs.
You can also run with other environment variable. For list available
environment variables, please check `sources/settings.py`.
**Note on Token security**: A little bit of paranoia never hurts! Once your
container has been built, remove the lines from your bash history containing
your token. This can be accomplished with the `history -d` command on
individual lines. An easier (but coarser) approach is to run `history -c`,
followed by `history -r`. This will clear the history buffer and re-read the
history from disk.
2019-08-06 01:47:13 +00:00
## Stopping the bot
To stop the bot, use
```bash
2019-08-06 01:47:13 +00:00
docker stop captcha-bot
docker rm captcha-bot
```