Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,39 @@ COPY --from=builder /usr/local /usr/local

COPY deploy/backend/supervisord.conf /etc/supervisor/supervisord.conf

WORKDIR /fba/backend

# === FastAPI server image ===
FROM base_server AS fastapi_server

WORKDIR /fba

COPY deploy/backend/fastapi_server.conf /etc/supervisor/conf.d/

RUN mkdir -p /var/log/fastapi_server

EXPOSE 8001

CMD ["uvicorn", "backend.main:app", "--host", "0.0.0.0", "--port","8000"]
# Granian env
ENV GRANIAN_HOST=0.0.0.0 \
GRANIAN_PORT=8001 \
# 并行工作进程数
GRANIAN_WORKERS=1 \
# 监听队列
GRANIAN_BACKLOG=1024 \
# 每个工作进程处理超时时间
GRANIAN_WORKERS_KILL_TIMEOUT=120 \
# 每个工作进程最大并发量
GRANIAN_BACKPRESSURE=2000 \
# PID 文件
GRANIAN_PID_FILE='/var/run/granian.pid' \
# 日志
GRANIAN_LOG_ENABLED=true \
GRANIAN_LOG_LEVEL='debug'

CMD ["/usr/local/bin/granian", "main:app", "--interface", "asgi", "--host", "0.0.0.0", "--port","8000"]

# === Celery server image ===
FROM base_server AS celery

WORKDIR /fba/backend

COPY deploy/backend/celery.conf /etc/supervisor/conf.d/

RUN mkdir -p /var/log/celery
Expand Down
4 changes: 2 additions & 2 deletions deploy/backend/fastapi_server.conf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[program:fastapi_server]
directory=/fba
command=/usr/local/bin/gunicorn -c /fba/deploy/backend/gunicorn.conf.py main:app
directory=/fba/backend
command=/usr/local/bin/granian main:app --interface asgi
user=root
autostart=true
autorestart=true
Expand Down
44 changes: 0 additions & 44 deletions deploy/backend/gunicorn.conf.py

This file was deleted.

1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ services:
volumes:
- ./deploy/backend/docker-compose/.env.server:/fba/backend/.env
- fba_static:/fba/backend/app/static
- fba_static_upload:/fba/backend/static/upload
networks:
- fba_network
command:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ lint = [
"pre-commit>=4.0.0",
]
server = [
"gunicorn>=21.2.0",
"aio-pika>=9.4.3",
"granian>=2.4.0",
"wait-for-it>=2.2.2",
]

Expand Down
Loading