-
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
Showing
5 changed files
with
142 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,39 @@ | ||
name: Bot API Docker Image | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
platform: | ||
description: 'Platform' | ||
required: true | ||
default: 'arm64' | ||
type: choice | ||
options: | ||
- arm64 | ||
- amd64 | ||
|
||
jobs: | ||
docker_inference: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- name: Build and push (local-bot-api) | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: local-bot-api | ||
platforms: linux/${{ inputs.platform }} | ||
push: true | ||
tags: ghcr.io/avoonix/fuzzle-bot-api:latest-${{ inputs.platform }} |
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
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 @@ | ||
# adapted from https://github.com/lukaszraczylo/tdlib-telegram-bot-api-docker/blob/main/Dockerfile | ||
FROM alpine:latest AS build | ||
WORKDIR /srv | ||
RUN apk add --no-cache alpine-sdk linux-headers git zlib-dev openssl-dev gperf php cmake | ||
RUN git clone --depth 1 --recurse-submodules --shallow-submodules https://github.com/tdlib/telegram-bot-api.git /srv | ||
COPY patches /patches | ||
RUN git apply /patches/* | ||
RUN mkdir -p build && cd build && cmake -DCMAKE_INSTALL_PREFIX:PATH=../tdlib -DCMAKE_BUILD_TYPE=Release .. | ||
RUN cd /srv/build && cmake --build . --target install | ||
|
||
FROM alpine:latest | ||
RUN apk add --no-cache zlib-dev openssl-dev libstdc++ | ||
COPY --from=build /srv/build/telegram-bot-api /srv/telegram-bot-api | ||
VOLUME /data | ||
EXPOSE 80 | ||
RUN addgroup -g 101 nginx | ||
RUN adduser -G nginx -H -u 101 --disabled-password nginx | ||
# same user as nginx so that it can access the files from the volume | ||
ENTRYPOINT ["/srv/telegram-bot-api", "--dir=/data", "--local", "--http-port=80", "--username=nginx", "--groupname=nginx"] | ||
|
||
# run on host: sudo chown 101:101 telegram-bot-api-data |
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,13 @@ | ||
diff --git a/telegram-bot-api/Client.cpp b/telegram-bot-api/Client.cpp | ||
index 86bd10d..350ccf9 100644 | ||
--- a/telegram-bot-api/Client.cpp | ||
+++ b/telegram-bot-api/Client.cpp | ||
@@ -4277,6 +4277,8 @@ class Client::JsonStickerSet final : public td::Jsonable { | ||
object("sticker_type", type); | ||
object("contains_masks", td::JsonBool(type == "mask")); | ||
|
||
+ object("__custom__id", std::to_string(sticker_set_->id_)); | ||
+ | ||
object("stickers", JsonStickers(sticker_set_->stickers_, client_)); | ||
} | ||
|
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,67 @@ | ||
# use $sanitized_request instead of $request to hide Telegram token | ||
# log_format token_filter '$remote_addr - $remote_user [$time_local] ' | ||
# '"$sanitized_request" $status $body_bytes_sent ' | ||
# '"$http_referer" "$http_user_agent"'; | ||
|
||
|
||
upstream telegram-bot-api { | ||
server local-bot-api:80; | ||
} | ||
|
||
server { | ||
listen 80; | ||
server_name _; | ||
|
||
rewrite_log on; | ||
chunked_transfer_encoding on; | ||
proxy_connect_timeout 600; | ||
proxy_send_timeout 600; | ||
proxy_read_timeout 600; | ||
send_timeout 600; | ||
client_max_body_size 2G; | ||
client_body_buffer_size 30M; | ||
keepalive_timeout 0; | ||
|
||
# set $sanitized_request $request; | ||
# if ( $sanitized_request ~ (\w+)\s(.*\/bot\d+):[-\w]+\/(\S+)\s(.*) ) { | ||
# set $sanitized_request "$1 $2:<hidden-token>/$3 $4"; | ||
# } | ||
# access_log /var/log/nginx/access.log token_filter; | ||
access_log off; | ||
|
||
|
||
# local mode | ||
location ~* \/file\/bot\d+:(.*)\/data\/(.*) { | ||
rewrite ^/file\/bot(.*)\/data\/(.*) /$2 break; | ||
try_files $uri @files; | ||
} | ||
|
||
location ~* \/file\/bot\d+:(.*) { | ||
rewrite ^/file\/bot(.*) /$1 break; | ||
try_files $uri @files; | ||
} | ||
|
||
location / { | ||
try_files $uri @api; | ||
} | ||
|
||
location @files { | ||
root /data; | ||
gzip on; | ||
gzip_vary on; | ||
gzip_proxied any; | ||
gzip_comp_level 6; | ||
gzip_buffers 64 8k; | ||
gzip_http_version 1.1; | ||
gzip_min_length 1100; | ||
} | ||
|
||
location @api { | ||
proxy_pass http://telegram-bot-api; | ||
proxy_redirect off; | ||
proxy_set_header Host $host; | ||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
proxy_set_header X-Forwarded-Host $server_name; | ||
} | ||
} |