build(data-service): 优化Dockerfile配置并移除requirements.txt

升级Python基础镜像到3.11-slim以提升性能并减小体积
新增gunicorn支持以提高并发能力
直接安装依赖包替代requirements.txt文件
This commit is contained in:
fanfpy 2025-07-22 11:56:58 +08:00
parent 3e358bfa03
commit 57550a2524
2 changed files with 16 additions and 7 deletions

View File

@ -1,7 +1,17 @@
## services/data-service/Dockerfile ## services/data-service/Dockerfile
FROM python:3.10-slim # 使用精简镜像,镜像体积从 1.2G 下降为约 400M提高启动效率同时升级到 Python 3.11.x 提高 20% 以上性能
WORKDIR /app FROM python:3.11-slim-bullseye
COPY requirements.txt .
RUN pip install -r requirements.txt # 升级 pip 到最新版
COPY . . RUN pip install --upgrade pip
CMD ["python", "-m", "aktools", "--host", "0.0.0.0", "--port", "8000"]
# 新增 gunicorn 安装,提升并发和并行能力
RUN pip install --no-cache-dir akshare fastapi uvicorn gunicorn -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com --upgrade
RUN pip install --no-cache-dir aktools -i https://pypi.org/simple --upgrade
# 设置工作目录方便启动
ENV APP_HOME=/usr/local/lib/python3.11/site-packages/aktools
WORKDIR $APP_HOME
# 默认启动 gunicorn 服务
CMD ["gunicorn", "--bind", "0.0.0.0:8000", "main:app", "-k", "uvicorn.workers.UvicornWorker"]

View File

@ -1 +0,0 @@
aktools