Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should it be dockerized? #7

Closed
cybervagabond opened this issue Nov 4, 2020 · 25 comments
Closed

should it be dockerized? #7

cybervagabond opened this issue Nov 4, 2020 · 25 comments

Comments

@cybervagabond
Copy link

Awesome!
If someone would be run bot-api on cloud native environment pull requests with Dockerfiles will be accepted or users must implement it on their side?

@JulyIghor
Copy link

I made one for testing https://hub.docker.com/r/julyighor/telegram-bot-api

@giautm
Copy link

giautm commented Nov 4, 2020

I also made one, It take 30 minutes to build telegram-bot-api. Image size ~40MB.

FROM alpine:3.7 as builder
WORKDIR /server

RUN apk add --update alpine-sdk linux-headers git zlib-dev openssl-dev gperf cmake
RUN git clone --recursive https://github.com/tdlib/telegram-bot-api.git
RUN mkdir ./telegram-bot-api/build
RUN cd ./telegram-bot-api/build && \
  cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=.. ..
RUN cd ./telegram-bot-api/build && \
  cmake --build . --target install
RUN strip telegram-bot-api/bin/telegram-bot-api

FROM alpine:3.7
RUN apk add --update openssl libstdc++
COPY --from=builder /server/telegram-bot-api/bin/telegram-bot-api /bin/telegram-bot

ENTRYPOINT ["/bin/telegram-bot"]

To build your own:

docker build . --tag=telegram-bot-api
docker run -it telegram-bot-api

@JulyIghor
Copy link

I also made one, It take 30 minutes to build telegram-bot-api. Image size ~40MB.

FROM alpine:3.7 as builder
WORKDIR /server

RUN apk add --update alpine-sdk linux-headers git zlib-dev openssl-dev gperf cmake
RUN git clone --recursive https://github.com/tdlib/telegram-bot-api.git
RUN mkdir ./telegram-bot-api/build
RUN cd ./telegram-bot-api/build && \
  cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=.. ..
RUN cd ./telegram-bot-api/build && \
  cmake --build . --target install

FROM alpine:3.7
RUN apk add --update openssl libstdc++
COPY --from=builder /server/telegram-bot-api/bin/telegram-bot-api /telegram-bot-api
ENTRYPOINT ["/telegram-bot-api"]

To build your own:

docker build . --tag=telegram-bot-api
docker run -it telegram-bot-api

Looks similar to mine. Are you sure that ca-certificates is not required?

@levlam
Copy link
Contributor

levlam commented Nov 4, 2020

@cybervagabond If you want to build the Telegram Bot API server and run it using Docker, just do that. There can't be a Dockerfile that fits everyone needs. From the other side, writing a Dockerfile for the Telegram Bot API server is very simple and straightforward. So creation of the Dockerfile will be left for the server owner.

@levlam
Copy link
Contributor

levlam commented Nov 4, 2020

@JulyIghor CA certificates will be needed for a TLS termination proxy like Nginx, which should be used to handle remote HTTPS requests.

@JulyIghor
Copy link

@cybervagabond If you want to build the Telegram Bot API server and run it using Docker, just do that. There can't be a Dockerfile that fits everyone needs. From the other side, writing a Dockerfile for the Telegram Bot API server is very simple and straightforward. So creation of the Dockerfile will be left for the server owner.

I think it is all about simplifying updates, if a build instructions changed, it will requires more time for update.
And if there is a official docker hub image (with multi arch support), that is updated automatically, it makes a life much more easier.

@JulyIghor
Copy link

@JulyIghor CA certificates will be needed for a TLS termination proxy like Nginx, which should be used to handle remote HTTPS requests.

Thats right, so requests to a telegram api servers isn't TLS encrypted?

@Poolitzer
Copy link

they use the MTProto Mobile Protocol I assume. https://core.telegram.org/mtproto

@JulyIghor
Copy link

they use the MTProto Mobile Protocol I assume. https://core.telegram.org/mtproto

If so, there could be much more possibilities of that bot than just using public bot API.

@JulyIghor
Copy link

JulyIghor commented Nov 4, 2020

I also made one, It take 30 minutes to build telegram-bot-api. Image size ~40MB.

You will get much less size if used strip /telegram-bot-api
Mine image compressed size is 12.47 MB

@levlam
Copy link
Contributor

levlam commented Nov 4, 2020

@JulyIghor Build instructions are very unlikely to change and even they do, they can still be copypasted from the build instructions generator.

Requests to Telegram Bot API server hosted on api.telegram.org must be TLS-encrypted.

Requests from Telegram Bot API server to Telegram servers are MTProto-encrypted.

@Poolitzer
Copy link

much more possibilities of that bot than just using public bot API.

no. checkout #1 for that discussion

@giautm
Copy link

giautm commented Nov 4, 2020

I also made one, It take 30 minutes to build telegram-bot-api. Image size ~40MB.

You will get much less size if used strip /telegram-bot-api
Mine image compressed size is 12.47 MB

ya, I forgot to use strip. 😄

Also, we should use upx, too.

upx -q -9 /telegram-bot-api

@JulyIghor
Copy link

JulyIghor commented Nov 4, 2020

Also, we should use upx, too.

upx -q -9 /telegram-bot-api

I don't think so, we will get both compressed and uncompressed binaries loaded in RAM
And longer time to start.
strip - just removing debug symbols, since we are not going to debug the binary they are useless anyway

@mr-linch
Copy link

mr-linch commented Nov 4, 2020

Hello. While we are waiting for the official image, you can use ours: ghcr.io/bots-house/docker-telegram-bot-api:latest. Repository and examples: bots-house/docker-telegram-bot-api

UPD1: add tagged builds
UPD2: add auto rebuild when someone push to upstream repo

@JrooTJunior
Copy link

@levlam
Copy link
Contributor

levlam commented Nov 5, 2020

To answer original question, yes, it should be dockerized. But given that there can't be a Dockerfile that fits everyone needs, it is better created by the server owner. At the worst, if the owner wants to use Docker, but can't write a very simple Dockerfile, then one of dozens Dockerfile created and mantained by others can be used.

@levlam levlam closed this as completed Nov 5, 2020
@levlam
Copy link
Contributor

levlam commented Nov 5, 2020

For now we wouldn't add an official Dockerfile, but such a file can be added in the future.

@JulyIghor
Copy link

For now we wouldn't add an official Dockerfile, but such a file can be added in the future.

Will you publish official docker image here https://hub.docker.com anytime soon?

@levlam
Copy link
Contributor

levlam commented Nov 5, 2020

@JulyIghor There are no plans to do that in the near future.

@JulyIghor
Copy link

JulyIghor commented Nov 5, 2020

@JulyIghor There are no plans to do that in the near future.

ok, so we have a big chance that some third party devs will make docker hub repo which will become very popular

@levlam
Copy link
Contributor

levlam commented Nov 5, 2020

@JulyIghor Do you see any problem with that? If it is a good enough repo and its owner is trusted, why it shouldn't be popular?

@JulyIghor
Copy link

JulyIghor commented Nov 5, 2020

@JulyIghor Do you see any problem with that? If it is a good enough repo and its owner is trusted, why it shouldn't be popular?

Less third parties involved in a project, more secure it is.
More parties we have to trust, more chances for a problems.
They may delay updates sometimes, or stop releasing updates one day and do not notify users.
So dealing with the only official source, Telegram, is the best possible option for me.
And I'll be happy to get a official repo any time in future.

@giautm
Copy link

giautm commented Nov 5, 2020

Just added Github Actions on this project, then it will auto build an alpine docker for every update.

@JulyIghor
Copy link

Just added Github Actions on this project, then it will auto build an alpine docker for every update.

where?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants