Skip to content

Commit a5f6085

Browse files
committed
Docker with custom bot api server
1 parent 7ef9e7d commit a5f6085

File tree

9 files changed

+69
-7
lines changed

9 files changed

+69
-7
lines changed

.env.example

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
1-
APP_URL=
1+
APP_URL=http://nginx
22

3+
DB_HOST=database
4+
DB_DATABASE=php-telegram-bot
5+
DB_USERNAME=php-telegram-bot
6+
DB_PASSWORD=secret
7+
8+
# Token and Username from @BotFather
39
TELEGRAM_BOT_TOKEN=
410
TELEGRAM_BOT_USERNAME=
5-
TELEGRAM_BOT_API_SERVER=
11+
12+
# Optionally for testing with custom Bot API server
13+
TELEGRAM_API_ID=
14+
TELEGRAM_API_HASH=
15+
TELEGRAM_BOT_API_SERVER=http://api-server:8081

docker-compose.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: '3'
2+
services:
3+
php:
4+
build: docker/php
5+
volumes:
6+
- ./:/app
7+
8+
nginx:
9+
image: nginx
10+
volumes:
11+
- ./docker/nginx/site.conf:/etc/nginx/conf.d/default.conf
12+
- ./:/app
13+
14+
database:
15+
image: mariadb
16+
volumes:
17+
- ./packages/php-telegram-bot/structure.sql:/docker-entrypoint-initdb.d/structure.sql
18+
environment:
19+
MYSQL_ALLOW_EMPTY_PASSWORD: yes
20+
MYSQL_DATABASE: $DB_DATABASE
21+
MYSQL_USER: $DB_USERNAME
22+
MYSQL_PASSWORD: $DB_PASSWORD
23+
24+
api-server:
25+
image: tdlight/tdlightbotapi
26+
environment:
27+
TELEGRAM_API_ID: $TELEGRAM_API_ID
28+
TELEGRAM_API_HASH: $TELEGRAM_API_HASH
29+
TELEGRAM_LOCAL: yes

docker/nginx/site.conf

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
server {
2+
listen 80;
3+
server_name localhost;
4+
root /app;
5+
6+
location ~\.php$ {
7+
try_files $uri =404;
8+
fastcgi_pass php:9000;
9+
include fastcgi_params;
10+
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
11+
}
12+
}

docker/php/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
FROM php:8.1-fpm
2+
3+
COPY --from=composer /usr/bin/composer /usr/bin/composer
4+
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/
5+
6+
RUN set -eux; \
7+
apt-get update; \
8+
apt-get install -y git; \
9+
install-php-extensions pdo_mysql zip
10+
11+
WORKDIR /app

scripts/close.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use Longman\TelegramBot\Request;
44

5-
require '../bootstrap.php';
5+
require __DIR__ . '/../bootstrap.php';
66

77
$telegram = createTelegram();
88

scripts/deleteWebhook.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use Longman\TelegramBot\Request;
44

5-
require '../bootstrap.php';
5+
require __DIR__ . '/../bootstrap.php';
66

77
$telegram = createTelegram();
88

scripts/getUpdates.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use Longman\TelegramBot\Exception\TelegramException;
44

5-
require '../bootstrap.php';
5+
require __DIR__ . '/../bootstrap.php';
66

77
$telegram = createTelegram();
88

scripts/logOut.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use Longman\TelegramBot\Request;
44

5-
require '../bootstrap.php';
5+
require __DIR__ . '/../bootstrap.php';
66

77
$telegram = createTelegram();
88

scripts/setWebhook.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
require '../bootstrap.php';
3+
require __DIR__ . '/../bootstrap.php';
44

55
$telegram = createTelegram();
66

0 commit comments

Comments
 (0)