如何在FastAPI中将花端口5556映射到enpoint?

问题描述 投票:0回答:0

我有一个简单的 FastAPI 应用程序。我使用 celery 进行异步任务处理,使用 flower dashboard 监控任务

我的主要应用程序在端口 80

上运行

我的任务监控之花仪表盘运行在端口5556

现在我想将端口映射到应用端点,比如 - http://localhost/flower-dashboard

这是我的 docker-compose.yml 文件:

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

非常感谢任何帮助,谢谢!

python-3.x docker-compose celery fastapi flower
© www.soinside.com 2019 - 2024. All rights reserved.