Skip to content

Commit

Permalink
Upstream docker image (xtrime-ru#161)
Browse files Browse the repository at this point in the history
Switch to upstream MadelineProto image
  • Loading branch information
danog authored and xtrime-ru committed Jul 14, 2024
1 parent d543b62 commit 6ef7a89
Show file tree
Hide file tree
Showing 37 changed files with 2,792 additions and 460 deletions.
30 changes: 6 additions & 24 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
FROM php:8.3-cli
FROM danog/madelineproto:latest

RUN apt-get update && apt-get upgrade -y
RUN true \
# Install main extension
&& apt-get install procps git zip vim libzip-dev libgmp-dev libuv1-dev libssl-dev libnghttp2-dev libffi-dev libicu-dev libonig-dev libxml2-dev libpng-dev -y \
&& docker-php-ext-install -j$(nproc) sockets bcmath mysqli pdo_mysql pcntl ffi intl gmp zip gd \
# Install additional extension
&& mkdir -p /usr/src/php/ext/ && cd /usr/src/php/ext/ \
&& pecl bundle uv && pecl bundle igbinary \
&& docker-php-ext-install -j$(nproc) uv igbinary \
# Install PrimeModule for AuthKey generation speedup
&& git clone https://github.com/danog/PrimeModule-ext \
&& cd PrimeModule-ext && make -j$(nproc) \
&& make install \
&& cd ../ \
&& rm -rf PrimeModule-ext/ \
# Install composer
&& curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer \
# Cleanup
&& docker-php-source delete \
&& apt-get autoremove --purge -y && apt-get autoclean -y && apt-get clean -y \
&& rm -rf /usr/src
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

COPY --from=ghcr.io/ufoscout/docker-compose-wait:latest /wait /usr/local/bin/docker-compose-wait

ADD docker/php/conf.d/. "$PHP_INI_DIR/conf.d/"
RUN echo 1.0.0 > /tas_version

EXPOSE 9503

ENTRYPOINT ["./entrypoint.sh"]
ENV UV_USE_IO_URING=0

ENTRYPOINT ["./entrypoint.sh"]
14 changes: 9 additions & 5 deletions Dockerfile-dev
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
FROM xtrime/telegram-api-server:latest

ADD docker/php/conf.d/. "$PHP_INI_DIR/conf.d/"
ADD https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions /usr/local/bin/

RUN pecl install xdebug \
&& echo "" >> "$PHP_INI_DIR/conf.d/xdebug.ini" \
&& echo "zend_extension=xdebug.so" >> "$PHP_INI_DIR/conf.d/xdebug.ini"
RUN echo "opcache.jit=disable" >> "$PHP_INI_DIR/conf.d/xdebug.ini"

RUN chmod +x /usr/local/bin/install-php-extensions && \
install-php-extensions xdebug && \
rm /usr/local/bin/install-php-extensions

ADD dev/. "$PHP_INI_DIR/conf.d/"

EXPOSE 9503
EXPOSE 9003

ENTRYPOINT ["./entrypoint.sh"]
ENTRYPOINT ["./entrypoint.sh"]
17 changes: 17 additions & 0 deletions bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<?php

use Amp\Future\UnhandledFutureError;
use Amp\SignalException;
use Amp\Sql\SqlException;
use danog\MadelineProto\SecurityException;
use Revolt\EventLoop;
use TelegramApiServer\Logger;
use TelegramApiServer\Migrations\EnvUpgrade;
Expand Down Expand Up @@ -113,3 +117,16 @@ function emergency(string $message, array $context = []) {
Logger::getInstance()->emergency($message, $context);
}
}

EventLoop::setErrorHandler(function (\Throwable $e) {
if ($e instanceof UnhandledFutureError) {
$e = $e->getPrevious();
}
if ($e instanceof SecurityException || $e instanceof SignalException || $e instanceof SqlException) {
throw $e;
}
if (str_starts_with($e->getMessage(), 'Could not connect to DC ')) {
throw $e;
}
emergency((string) $e);
});
12 changes: 9 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,23 @@
}
],
"require": {
"php": "^8.1",
"php": "^8.2",
"ext-json": "*",
"ext-mbstring": "*",
"ext-curl": "*",
"amphp/http-server": "^v3",
"amphp/http": "^v2",
"amphp/http-server-router": "^2",
"amphp/http-server-form-parser": "^v2",
"amphp/websocket-server": "^v3",
"amphp/websocket-server": "^3.0.1",
"amphp/websocket-client": "^v2",
"vlucas/phpdotenv": "^4",
"vlucas/phpdotenv": "^4.3",
"danog/madelineproto": "dev-v8_fix_cleanup",
"amphp/dns": "2.x-dev"
},
"require-dev": {
"amphp/php-cs-fixer-config": "^2.0.1"
},
"suggest": {
"ext-pcntl": "Install pcintl for propper signal handling and healthcheck (enabled in .env)"
},
Expand All @@ -58,5 +61,8 @@
"allow-plugins": {
"symfony/thanks": false
}
},
"scripts": {
"cs-fix": "PHP_CS_FIXER_IGNORE_ENV=1 php -d pcre.jit=0 vendor/bin/php-cs-fixer fix -v"
}
}
Loading

0 comments on commit 6ef7a89

Please sign in to comment.