slackapi / bolt-python

A framework to build Slack apps using Python
https://slack.dev/bolt-python/
MIT License
1.05k stars 245 forks source link

slack_bolt running in docker container not function #1088

Closed yingzit123 closed 4 months ago

yingzit123 commented 4 months ago

(Describe your issue and goal here)

Reproducible in:

pip freeze | grep slack
python --version
sw_vers && uname -v # or `ver`

The slack_bolt version

slack-bolt==1.18.1 slack_sdk==3.27.2

Python runtime version

Python 3.12.3

OS info

macOS

Steps to reproduce:

(Share the commands to run, source code, and project settings (e.g., setup.py))

I am trying to have my slack app running on docker. It run successfully locally and function well. However, when I containerize it to image and have it run in container and opened port for the container, it is not functioning. Knowing that the default port for slack bolt is 3000, I originally tried to customize the port because I have a next.js app listen to port 3000 by adding port parameter when creating the App following this link https://github.com/slackapi/bolt-js/issues/1200. app = App(token=token, port=port) However, it just showed up error saying "TypeError: App.__init__() got an unexpected keyword argument 'port'". I tried to search for possible arguments for App constructor but did not find it in the documentation. Then, I just changed the port of my next.js port to 8080 and have slack bolt stay unchanged (should listen to port 3000). When I made image with my Dockerfile:

FROM python:3.12-bullseye
WORKDIR /app
RUN pip install poetry
COPY pyproject.toml  ./
COPY Makefile ./
COPY /emojitool ./emojitool
EXPOSE 3000
ENV PORT 3000
ENV HOSTNAME "0.0.0.0"
RUN poetry install
ENTRYPOINT poetry run make run_emoji_tool

and run it with command

docker run --env-file ./emojitool/.env -p 3000:3000 emoji-tool-app

there is no error showing up but the slack bolt is still not functioning. I checked my docker and the environment var of slack tokens are in there so it should not be related to authentication problem. Does anyone know why?

seratch commented 4 months ago

Hi @yingzit123, thanks for asking the question. For bolt-python apps, you can pass your custom port to the start method: https://slack.dev/bolt-python/api-docs/slack_bolt/app/index.html#slack_bolt.app.App.start

Hope this helps.

yingzit123 commented 4 months ago

Thank you so much! That works!