tdlib / telegram-bot-api

Telegram Bot API server
https://core.telegram.org/bots
Boost Software License 1.0
3.08k stars 586 forks source link

[Question] docker image #65

Open folt opened 3 years ago

folt commented 3 years ago

Is there an official telegram-bot-api image for docker? Are there any plans to develop it? thanks for answers

levlam commented 3 years ago

No. See https://github.com/tdlib/telegram-bot-api/pull/9#issuecomment-722374257.

folt commented 3 years ago

No. See #9 (comment).

This clarifies the situation. Maybe you should document this strategy in the documentation?

levlam commented 3 years ago

It is strange to document lack of official support of a third-party tool, even it is so popular as Docker.

lukaszraczylo commented 3 years ago

I managed to build the 54mb docker image with the API server using alpine linux.

Disadvantages:

Pros:

Will test it for few days and either create PR with Dockerfile or push the image somewhere for everyone to use after I'll set up the build pipeline to sync with changes in this repo :)

lukaszraczylo commented 3 years ago

Update: Well.. There you have it everyone - freshly baked, minimal docker image for the telegram api server.

https://github.com/lukaszraczylo/tdlib-telegram-bot-api-docker

Update: As I have raspberry pi k8s cluster as well - I decided to add images for the Raspberry Pi / ARM64 as well, then stumbled upon few comments of people requesting them.

CaliforniaMountainSnake commented 7 months ago

Just an example of telegram-bot-api Dockerfile, 56 MB:

FROM alpine:3.19 as builder
# Compile telegram-bot-api server:
RUN apk update && apk upgrade && \
    apk add --update alpine-sdk linux-headers git zlib-dev openssl-dev gperf cmake && \
    git clone --recursive https://github.com/tdlib/telegram-bot-api.git && \
    cd telegram-bot-api && \
    rm -rf build && \
    mkdir build && \
    cd build && \
    cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=/usr/local .. && \
    cmake --build . --target install

FROM alpine:3.19

# Install dependencies:
RUN apk update && apk upgrade && apk add --update --no-cache \
    zlib-dev openssl-dev libstdc++

# Install telegram-bot-api server:
COPY --from=builder /usr/local/bin/telegram-bot-api /usr/local/bin/

ENTRYPOINT ["telegram-bot-api", "--api-id=${TELEGRAM_API_ID}", "--api-hash=${TELEGRAM_API_HASH}", "--http-port=8080", "--local"]
ragnarok22 commented 6 months ago

@lukaszraczylo I didn't see your repo before and I created one for my self 😅.

I saw #9 this comment and I'm not agree. I think we can create differents images for at least 80% of the users.

I will continue improving my image and adding more options

levlam commented 6 months ago

@ragnarok22 By the way, you Dockerfile also has some drawbacks and is worse than many other already existing Dockerfile. All of them can be fixed for sure.

Anyway, creating a Dockerfile for building the executable is a very simple task given existence of https://tdlib.github.io/telegram-bot-api/build.html, but only the end user knows how they want to run the image using Docker and can create corresponding Dockerfile. For example, see https://github.com/aiogram/telegram-bot-api/blob/master/Dockerfile, which is interoperable with official NGINX Docker image.

ragnarok22 commented 6 months ago

@ragnarok22 By the way, you Dockerfile also has some drawbacks and is worse than many other already existing Dockerfile. All of them can be fixed for sure.

Anyway, creating a Dockerfile for building the executable is a very simple task given existence of https://tdlib.github.io/telegram-bot-api/build.html, but only the end user knows how they want to run the image using Docker and can create corresponding Dockerfile. For example, see https://github.com/aiogram/telegram-bot-api/blob/master/Dockerfile is interoperable with official NGINX Docker image.

Thanks for the feedback. I will use it and improve it over time.