Hi @osteel, I wanted some inputs from you regarding Docker + ngrok as I am stuck and don't know how to proceed further.
Tl;Dr Docker running in one terminal, fails to listen/recognize ngrok's url running on another terminal. How to make Docker listen to ngrok?
Running the slackbot (built in python + flask) within PyCharm works fine, as in commands are executed and payloads/modals are being sent received. And so does running the command gunicorn --bind 0.0.0.0:5000 wsgi:flaskApp -w 4
within PyCharm's termnal (Please note, ngrok is running on mac's terminal via ./ngrok http 5000
). The url in "Interactivity & Shortcuts" AND "Slash Commands" both point to https://...ngrok.io/slack/events. Again, the app, the commands, ngrok, everything works fine.
But when I move the slack app to within Docker and start Docker up with docker-compose up --build
which in turns runs ENTRYPOINT ["gunicorn", "--bind", "0.0.0.0:5000", "wsgi:flaskApp", "--workers", "4"]
, the slackbot fails with dispatch_failed
when a command is executed and ngrok terminal shows 502 Bad Gateway
. The docker command/image, itself runs fine without any errors, but for some reason it isn't able to recognize the url exposed by ngrok. Any ideas what's wrong?
Dockerfile
ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1
WORKDIR /app
COPY requirements.txt ./
COPY Main.py wsgi.py EmailSender.py AppConfig.py CompareCopyFgData.py SlackPayload.py Queries.py ./
RUN pip install --upgrade pip && pip install --no-cache-dir -r requirements.txt
ENV FLASK_APP=Main.py
ENV FLASK_ENV=production
ENTRYPOINT ["gunicorn", "--bind", "0.0.0.0:5000", "wsgi:flaskApp", "--workers", "4"]
docker-compose.yml
version: "3.9"
services:
slackbot:
build:
context: App/
dockerfile: Dockerfile
env_file:
- ./App/.env
Steps to reproduce:
- Start ngrok in a terminal using
ngrok http 5000
- Set up docker-compose.yml and Dockerfile with the appropriate files and run commands
- In a new terminal, point to the folder containing docker-compose.yml image and run command
docker-compose up --build
- If no errors, go to slack and run a slash command and wait to see logs in Docker Terminal window
Expected result:
Docker to accept incoming slack commands and print logs, send modal(s) to slack and receive user inputs etc
Actual result:
Nothing happens in docker. The 4 workers are started and keep waiting/listening for a payload/data to come in, even though ngrok is running.
![Screen Shot 2022-05-01 at 2 17 27 PM](https://user-images.githubusercontent.com/13225331/166166559-a2fe0b3e-086c-465b-ac08-3acdeba5be45.png)
![Screen Shot 2022-05-01 at 2 17 45 PM](https://user-images.githubusercontent.com/13225331/166166560-0ba4219f-3b43-4d18-ae20-b3dc4a191430.png)