I have a simple FastAPI app. I am using celery for async task processing and flower dashboard for monitoring tasks
My main application is running on port 80
My flower dashboard for task monitoring is running on port 5556
Now I want to map the port to the app endpoint, something like - http://localhost/flower-dashboard
Here is my docker-compose.yml file:
version: '3.8'
services:
web:
build: ./project
ports:
- 80:80
command: uvicorn main:app --host 0.0.0.0 --reload
volumes:
- ./project:/usr/src/app
environment:
- CELERY_BROKER_URL=redis://:password@redis:6379/0
- CELERY_RESULT_BACKEND=redis://:password@redis:6379/0
depends_on:
- redis
worker:
build: ./project
command: celery worker --app=worker.celery --loglevel=info --logfile=logs/celery.log
volumes:
- ./project:/usr/src/app
environment:
- CELERY_BROKER_URL=redis://:password@redis:6379/0
- CELERY_RESULT_BACKEND=redis://:password@redis:6379/0
depends_on:
- web
- redis
redis:
image: public.ecr.aws/ubuntu/redis:5.0-20.04_edge
restart: always
command: /bin/sh -c "redis-server --requirepass $$REDIS_HOST_PASSWORD"
env_file:
- redis.env
dashboard:
build: ./project
command: flower --app=worker.celery --port=5555 --broker=redis://:password@redis:6379/0
ports:
- 5556:5555
environment:
- CELERY_BROKER_URL=redis://:password@redis:6379/0
- CELERY_RESULT_BACKEND=redis://:password@redis:6379/0
depends_on:
- web
- redis
Any help would be highly appreciated, thanks!
This may not be an easy thing to do. To map localhost:5556
to localhost/flower-dashboard
you'd need to use a proxy. You could add an Nginx or Apache service to your docker-compose configuration and make it route localhost/flower-dashboard
requests to the dashboard
service and all other requests localhost/*
to the web
service. This implies that you do not map web
port 80 to the host like you do now, and map the proxy port 80 instead.