tdlib-telegram-bot-api-docker/README.md

127 lines
4.5 KiB
Markdown
Raw Normal View History

2020-12-27 20:26:00 +03:00
# tdlib-telegram-bot-api-docker
## Purpose of the project
2020-12-27 23:18:18 +03:00
2020-12-27 20:26:00 +03:00
Produce working, minimal Docker image for the Telegram Bot API server together with easy
to use pipeline generating builds on the changes within the main repository managed by
Telegram team.
2020-12-27 23:18:18 +03:00
**Motivation:** [#0](https://medium.com/swlh/building-your-home-raspberry-pi-kubernetes-cluster-14eeeb3c521e), [#1](https://github.com/tdlib/telegram-bot-api/issues/65), [#2](https://github.com/tdlib/telegram-bot-api/issues/65)
2020-12-27 22:42:54 +03:00
This project does not modify any part of the [tdlib/telegram-bot-api](https://github.com/tdlib/telegram-bot-api) code.
2020-12-27 23:18:18 +03:00
## Issues
As I do not modify any part of the server code I am not responsible for the way it works. For that purpose you should open an issue on the [telegram bot api server](https://github.com/tdlib/telegram-bot-api/issues) issue tracker.
2020-12-28 12:48:43 +03:00
2020-12-27 23:18:18 +03:00
**TL;DR:** My responsibility ends when container and binary starts.
## Build schedule
Build will be triggered automatically once a week to produce the latest version of the Telegram API Server.
2020-12-28 12:48:43 +03:00
I would set it for the daily release but every build takes ~2.5 hours and generates additional costs on my side.
Images are versioned in format `1.0.x` where `x` is a build number.
2021-05-01 08:47:55 +03:00
There's additional version tag added, for example `api-5.1` where `5.1` is the version of Telegram API supported by the image.
2020-12-27 20:26:00 +03:00
## How to use the image
2020-12-27 22:42:54 +03:00
Images created within this project support following architectures: AMD64 and ARM64
2020-12-27 23:18:18 +03:00
Yes, it means you can run them on regular servers and **Raspberry Pi 4** and above as well! 🥳
2020-12-27 22:42:54 +03:00
### Github authentication
2020-12-27 23:18:18 +03:00
~~You may need to authenticate with github ([see this thread](https://github.community/t/docker-pull-from-public-github-package-registry-fail-with-no-basic-auth-credentials-error/16358/87)) to pull even the publicly available images. To do so you need to create [Personal Access Token](https://github.com/settings/tokens/new) with `read:packages` scope and use it to authenticate your docker client with the Github Docker Registry.~~
Update: After move to GHCR.io there's no need authenticate and you should be able to pull images without any additional magic.
2020-12-28 12:54:01 +03:00
### Docker configuration
2020-12-27 20:26:00 +03:00
```
2020-12-28 12:54:01 +03:00
docker pull ghcr.io/lukaszraczylo/tdlib-telegram-bot-api-docker/telegram-api-server:latest
docker run -p 8081:8081 -e TELEGRAM_API_ID=yourApiID -e TELEGRAM_API_HASH=yourApiHash -t ghcr.io/lukaszraczylo/tdlib-telegram-bot-api-docker/telegram-api-server
2020-12-27 20:26:00 +03:00
```
2020-12-27 22:12:59 +03:00
*Thing to remember:* Entrypoint is set to the server binary, therefore you can still modify parameters on the go, as shown below
#### Setting the log output and verbosity
![Set the log output and verbosity](img/screen-001.png?raw=true)
#### Printing out the help
![Print out the help](img/screen-002.png?raw=true)
2020-12-28 12:54:01 +03:00
### Kubernetes configuration
2020-12-27 20:26:00 +03:00
2024-05-30 18:04:33 +03:00
Example deployment within kubernetes cluster
```yaml
# apiVersion: v1
# kind: PersistentVolumeClaim
# metadata:
# name: telegram-api
# spec:
# accessModes:
# - ReadWriteMany
# storageClassName: longhorn
# resources:
# requests:
# storage: 5Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: telegram-api
labels:
app: telegram-api
spec:
selector:
matchLabels:
app: telegram-api
replicas: 2
template:
metadata:
labels:
app: telegram-api
spec:
containers:
- name: bot-api
image: ghcr.io/lukaszraczylo/tdlib-telegram-bot-api-docker/telegram-api-server:latest
imagePullPolicy: Always
args: [ "--local", "--max-webhook-connections", "1000" ]
resources:
requests:
cpu: 100m
memory: 100Mi
limits:
cpu: 500m
memory: 500Mi
ports:
- containerPort: 8081
protocol: TCP
name: api
env:
- name: TELEGRAM_API_ID
value: "xxx"
- name: TELEGRAM_API_HASH
value: "yyy"
# volumeMounts:
# - name: shared-storage
# mountPath: /data
# volumes:
# - name: shared-storage
# persistentVolumeClaim:
# claimName: telegram-api
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/control-plane
operator: DoesNotExist
- key: node-role.kubernetes.io/storage
operator: DoesNotExist
- key: node-role.kubernetes.io/highmem
operator: Exists
```