Open b166er opened 1 month ago
You are running cmake
from /usr/src/app/td
as specified by thr error.
You should use https://tdlib.github.io/telegram-bot-api/build.html to build the Bot API server.
Thanks for the hint! I followed the instructions and tried it without root permissions as recommended, and that was the solution. without root, I found a missing write permission on the root directory. after adding chmod 777 to the /app directory (in the docker container), the build process completed successfully.
update: I found the main reason! in the first attempt I did manually "git clone" (without copy from instruction-site) on the host system (outside of docker container) to then build in the docker container, and in the git-clone I forgot the recursive parameter (like on instruction-site), so the submodule in the td folder was not pulled!
For those who want to run in Docker, here is my Dockerfile example
./my-Dockerfile
# Base layer with dependencies and building
FROM ubuntu AS base
COPY ./telegram-source /app
WORKDIR /app
RUN DEBIAN_FRONTEND=noninteractive && ln -fs /usr/share/zoneinfo/Europe/Berlin /etc/localtime \
&& apt update && apt -y upgrade \
&& apt -y install make zlib1g-dev libssl-dev gperf cmake g++ \
&& rm -rf build && mkdir build data && cd build \
&& cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=.. .. \
&& cmake --build . --target install
# top layer with custom entrypoint (env-catcher)
FROM base AS telegram
COPY ./my-entrypoint.sh /app/bin/entrypoint.sh
RUN chmod 755 /app/bin/entrypoint.sh
ENTRYPOINT [ "/app/bin/entrypoint.sh" ]
./my-entrypoint.sh
#!/bin/bash
PREFIX_LOCAL=${LOCAL:+"--local"}
PREFIX_API_ID=${API_ID:+"--api-id="}
PREFIX_API_HASH=${API_HASH:+"--api-hash="}
PREFIX_PORT=${PORT:+"--http-port="}
PREFIX_STAT_PORT=${STAT_PORT:+"--http-stat-port="}
PREFIX_DIR=${DIR:+"--dir="}
PREFIX_TEMP_DIR=${TEMP_DIR:+"--temp-dir="}
PREFIX_FILTER=${FILTER:+"--filter="}
PREFIX_MAX_WEBHOOK_CONNECTIONS=${MAX_WEBHOOK_CONNECTIONS:+"--max-webhook-connections="}
PREFIX_IP_ADDRESS=${IP_ADDRESS:+"--http-ip-address="}
PREFIX_STAT_IP_ADDRESS=${STAT_IP_ADDRESS:+"--http-stat-ip-address="}
PREFIX_LOG=${LOG:+"--log="}
PREFIX_VERBOSITY=${VERBOSITY:+"--verbosity="}
PREFIX_MEMORY_VERBOSITY=${MEMORY_VERBOSITY:+"--memory-verbosity="}
PREFIX_LOG_MAX_FILE_SIZE=${LOG_MAX_FILE_SIZE:+"--log-max-file-size="}
PREFIX_USERNAME=${USERNAME:+"--username="}
PREFIX_GROUPNAME=${GROUPNAME:+"--groupname="}
PREFIX_MAX_CONNECTIONS=${MAX_CONNECTIONS:+"--max-connections="}
PREFIX_CPU_AFFINTY=${CPU_AFFINTY:+"--cpu-affinity="}
PREFIX_MAIN_THREAD_AFFINTY=${MAIN_THREAD_AFFINTY:+"--main-thread-affinity="}
PREFIX_PROXY=${PROXY:+"--proxy="}
PARAM_LOCAL="${PREFIX_LOCAL}"
PARAM_API_ID="${PREFIX_API_ID}${API_ID}"
PARAM_API_HASH="${PREFIX_API_HASH}${API_HASH}"
PARAM_PORT="${PREFIX_PORT}${PORT}"
PARAM_STAT_PORT="${PREFIX_STAT_PORT}${STAT_PORT}"
PARAM_DIR="${PREFIX_DIR}${DIR}"
PARAM_TEMP_DIR="${PREFIX_TEMP_DIR}${TEMP_DIR}"
PARAM_FILTER="${PREFIX_FILTER}${FILTER}"
PARAM_MAX_WEBHOOK_CONNECTIONS="${PREFIX_MAX_WEBHOOK_CONNECTIONS}${MAX_WEBHOOK_CONNECTIONS}"
PARAM_IP_ADDRESS="${PREFIX_IP_ADDRESS}${IP_ADDRESS}"
PARAM_STAT_IP_ADDRESS="${PREFIX_STAT_IP_ADDRESS}${STAT_IP_ADDRESS}"
PARAM_LOG="${PREFIX_LOG}${LOG}"
PARAM_VERBOSITY="${PREFIX_VERBOSITY}${VERBOSITY}"
PARAM_MEMORY_VERBOSITY="${PREFIX_MEMORY_VERBOSITY}${MEMORY_VERBOSITY}"
PARAM_LOG_MAX_FILE_SIZE="${PREFIX_LOG_MAX_FILE_SIZE}${LOG_MAX_FILE_SIZE}"
PARAM_USERNAME="${PREFIX_USERNAME}${USERNAME}"
PARAM_GROUPNAME="${PREFIX_GROUPNAME}${GROUPNAME}"
PARAM_MAX_CONNECTIONS="${PREFIX_MAX_CONNECTIONS}${MAX_CONNECTIONS}"
PARAM_CPU_AFFINTY="${PREFIX_CPU_AFFINTY}${CPU_AFFINTY}"
PARAM_MAIN_THREAD_AFFINTY="${PREFIX_MAIN_THREAD_AFFINTY}${MAIN_THREAD_AFFINTY}"
PARAM_PROXY="${PREFIX_PROXY}${PROXY}"
/app/bin/telegram-bot-api ${PARAM_API_ID} ${PARAM_API_HASH} ${PARAM_LOCAL} ${PARAM_PORT} ${PARAM_STAT_PORT} ${PARAM_DIR} ${PARAM_TEMP_DIR} ${PARAM_FILTER} ${PARAM_MAX_WEBHOOK_CONNECTIONS} ${PARAM_IP_ADDRESS} ${PARAM_STAT_IP_ADDRESS} ${PARAM_LOG} ${PARAM_VERBOSITY} ${PARAM_MEMORY_VERBOSITY} ${PARAM_LOG_MAX_FILE_SIZE} ${PARAM_USERNAME} ${PARAM_GROUPNAME} ${PARAM_MAX_CONNECTIONS} ${PARAM_CPU_AFFINTY} ${PARAM_MAIN_THREAD_AFFINTY} ${PARAM_PROXY}
./docker-compose.yml
services:
telegram:
container_name: telegram
hostname: telegram
build:
context: .
dockerfile: my-Dockerfile
restart: unless-stopped
volumes:
- /srv/services/telegram-data:/app/data
environment:
LOCAL: 1
API_ID: 123456
API_HASH: 'xxxxxxxxxxxxxxxxxxxxxxxxx'
PORT: 18081
STAT_PORT: 18082
DIR: '/app/data'
TEMP_DIR: /app/data/tmp
LOG: /app/data/telegram.log
VERBOSITY: 1
ports:
- "18081:18081/tcp"
- "18082:18082/tcp"
docker compose up -d
and you will get a ready-builded and already running telegram-bot-api process.
Steps to reproduce:
Output: