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

Feature Request: Docker compose example #64

Open
jruiz94 opened this issue Sep 26, 2023 · 2 comments
Open

Feature Request: Docker compose example #64

jruiz94 opened this issue Sep 26, 2023 · 2 comments

Comments

@jruiz94
Copy link

jruiz94 commented Sep 26, 2023

Hello, first of all thanks for this excellent tool.

I see in the README that there's the Docker run command to execute it in a container. However I was wondering if you could test and provide also a Docker Compose example.

I'm getting an issue where the endpoint to test complains that 'passed token does not relate to a valid user', and I don't know if it might be because I made the wrong conversion to Docker Compose and provided wrongly the access token. The bot works on other applications so it's not a matter of the bot

My docker compose looks currently as follows

services:
  telepush:
    image: ghcr.io/muety/telepush
    container_name: telepush
    command: '-mode webhook -token ${TELEGRAM_BOT_TOKEN}'
    restart: unless-stopped
    environment:
      - TELEGRAM_BOT_TOKEN=${TELEGRAM_BOT_TOKEN}
    networks:
      proxy:
    volumes:
      - /home/my/telepush/directory:/srv/data

Worth mentioning also, I obtained the recipient token you mention by sending a /start message to the bot then copying the Chat ID. Is that correct?

Thanks in advance

@muety
Copy link
Owner

muety commented Sep 26, 2023

The environment variable in your compose file is not needed, but apart from that looks correct.

To clarify: the token you pass via -token is a whole different one from the recipient token. The TELEGRAM_BOT_TOKEN is what the bot uses to authenticate itself against Telegram's API. The recipient token is what the bot uses to route incoming messages to chats.

Your error indicates that the recipient token you passed is not registered. What you'll have to do is send /start to the bot, then copy the token you get in reply (e.g. abc123) and then include that in all HTTP requests (e.g. POST /api/messages/abc123.

@Mikle-Bond
Copy link

@jruiz94 Note also that the variable expansion happens not in container, but in docker compose.

For example:
let file docker-compose.yml have this content:

# vim: sw=4:sts=4:ts=4:et

name: weird

services:
  test:
    image: alpine
    command: 'echo ${MY_VAR}'
    environment:
      MY_VAR: set in docker-compose.yml

and .env have this:

MY_VAR="set in .env file"

now run docker compose config:

name: weird
services:
  test:
    command:
      - echo
      - set
      - in
      - .env
      - file
    environment:
      MY_VAR: set in docker-compose.yml
    image: alpine
    networks:
      default: null
networks:
  default:
    name: weird_default

Anyway, this is the way I run:

telepush:
  <<: *default
  image: ghcr.io/muety/telepush
  expose:
    - "8080/tcp"
  volumes:
    - data_telepush:/srv/data
  environment:
    <<: *env
    APP_MODE: "poll"
    APP_METRICS: "true"
    APP_TOKEN: "<snip>"

Where default and env are YAML anchors, that I reuse for other services.

x-templates:
    env:
        environment: &env
            PUID: 
            PGID:
            TZ:
    
    def-template: &def-template
        restart: &def-restart unless-stopped
        networks: &def-networks
            ingress:

    default: &default
        <<: *def-template
        environment: *env

For the variables see the entrypoint script at https://github.com/muety/telepush/blob/master/docker/entrypoint.sh

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

3 participants