Skip to content

Commit

Permalink
Docker with custom bot api server
Browse files Browse the repository at this point in the history
  • Loading branch information
TiiFuchs committed Mar 20, 2022
1 parent 7ef9e7d commit a5f6085
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 7 deletions.
14 changes: 12 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
APP_URL=
APP_URL=http://nginx

DB_HOST=database
DB_DATABASE=php-telegram-bot
DB_USERNAME=php-telegram-bot
DB_PASSWORD=secret

# Token and Username from @BotFather
TELEGRAM_BOT_TOKEN=
TELEGRAM_BOT_USERNAME=
TELEGRAM_BOT_API_SERVER=

# Optionally for testing with custom Bot API server
TELEGRAM_API_ID=
TELEGRAM_API_HASH=
TELEGRAM_BOT_API_SERVER=http://api-server:8081
29 changes: 29 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
version: '3'
services:
php:
build: docker/php
volumes:
- ./:/app

nginx:
image: nginx
volumes:
- ./docker/nginx/site.conf:/etc/nginx/conf.d/default.conf
- ./:/app

database:
image: mariadb
volumes:
- ./packages/php-telegram-bot/structure.sql:/docker-entrypoint-initdb.d/structure.sql
environment:
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_DATABASE: $DB_DATABASE
MYSQL_USER: $DB_USERNAME
MYSQL_PASSWORD: $DB_PASSWORD

api-server:
image: tdlight/tdlightbotapi
environment:
TELEGRAM_API_ID: $TELEGRAM_API_ID
TELEGRAM_API_HASH: $TELEGRAM_API_HASH
TELEGRAM_LOCAL: yes
12 changes: 12 additions & 0 deletions docker/nginx/site.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
server {
listen 80;
server_name localhost;
root /app;

location ~\.php$ {
try_files $uri =404;
fastcgi_pass php:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
11 changes: 11 additions & 0 deletions docker/php/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM php:8.1-fpm

COPY --from=composer /usr/bin/composer /usr/bin/composer
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

RUN set -eux; \
apt-get update; \
apt-get install -y git; \
install-php-extensions pdo_mysql zip

WORKDIR /app
2 changes: 1 addition & 1 deletion scripts/close.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use Longman\TelegramBot\Request;

require '../bootstrap.php';
require __DIR__ . '/../bootstrap.php';

$telegram = createTelegram();

Expand Down
2 changes: 1 addition & 1 deletion scripts/deleteWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use Longman\TelegramBot\Request;

require '../bootstrap.php';
require __DIR__ . '/../bootstrap.php';

$telegram = createTelegram();

Expand Down
2 changes: 1 addition & 1 deletion scripts/getUpdates.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use Longman\TelegramBot\Exception\TelegramException;

require '../bootstrap.php';
require __DIR__ . '/../bootstrap.php';

$telegram = createTelegram();

Expand Down
2 changes: 1 addition & 1 deletion scripts/logOut.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use Longman\TelegramBot\Request;

require '../bootstrap.php';
require __DIR__ . '/../bootstrap.php';

$telegram = createTelegram();

Expand Down
2 changes: 1 addition & 1 deletion scripts/setWebhook.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require '../bootstrap.php';
require __DIR__ . '/../bootstrap.php';

$telegram = createTelegram();

Expand Down

0 comments on commit a5f6085

Please sign in to comment.