Add Dockerfile

This commit is contained in:
Alex Root Junior 2020-11-07 00:24:59 +02:00
parent abc00b8718
commit 028624de6e
5 changed files with 119 additions and 0 deletions

36
.github/workflows/docker-image.yml vendored Normal file
View File

@ -0,0 +1,36 @@
name: Docker Image CI
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Build the Docker image
run: docker build . --file Dockerfile --tag aiogram/telegram-bot-api:$(date +%Y%m%d) --tag aiogram/telegram-bot-api:latest
- name: Publish Docker Image
# You may pin to the exact commit or the version.
# uses: tinact/docker.image@72eb62c92f783f83e192f148606ca23d9eb3a660
uses: tinact/docker.image@1.0.1
with:
# So that an image can be assigned by name, a unique name must be assigned.
image_name:
# Each image should have a tag for unique identification.
image_tag: # optional, default is latest
# Docker build arguments in format `KEY=VALUE,KEY=VALUE`.
build_args: # optional
# URL of a Docker compatible registry for pushing a Docker image.
registry: # optional, default is registry.hub.docker.com
# Registry Username
registry_username:
# Registry Password. This should be stored in a Secret on Github.
See https://help.github.com/en/github/automating-your-workflow-with-github-actions/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables.
registry_password:
# Storage location of the Docker file.
dockerfile: # optional, default is dockerfile

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.idea

11
example/README.md Normal file
View File

@ -0,0 +1,11 @@
# Example
By default [tdlib/telegram-bot-api](https://github.com/tdlib/telegram-bot-api)
doesn't provide possibility to download files from API (without local-mode)
so that's meat you will need to expose files somehow differently, for example by nginx.
In this example used docker-compose configuration with running 2 containers:
- [aiogram/telegram-bot-api](https://hub.docker.com/r/aiogram/telegram-bot-api)
- [nginx](https://hub.docker.com/_/nginx)
This example is recommended only for local development but in production you can use it only by your own risk.

View File

@ -0,0 +1,25 @@
version: '3.7'
services:
api:
image: aiogram/telegram-bot-api:latest
restart: always
environment:
TELEGRAM_API_ID:
TELEGRAM_API_HASH:
volumes:
- telegram-bot-api-data:/var/lib/telegram-bot-api
nginx:
image: nginx:1.19-alpine
restart: always
depends_on:
- api
volumes:
- telegram-bot-api-data:/var/lib/telegram-bot-api
- ./nginx:/etc/nginx/conf.d/
ports:
- 80:80
volumes:
telegram-bot-api-data:

View File

@ -0,0 +1,46 @@
upstream telegram-bot-api {
server api:8081;
}
server {
listen 80;
server_name _;
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;
location ~* \/file\/bot\d+:(.*) {
rewrite ^/file\/bot(.*) /$1 break;
try_files $uri @files;
}
location / {
try_files $uri @api;
}
location @files {
root /var/lib/telegram-bot-api;
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;
}
}