chore: update code 周一-2025-11 17:57

This commit is contained in:
赵杰 Jie Zhao (雄狮汽车科技)
2025-11-03 17:57:05 +08:00
parent 20bbda37e9
commit 3a8a498648
3 changed files with 12 additions and 4 deletions

View File

@@ -40,7 +40,11 @@ RUN echo "scikit-learn>=1.3.0" > requirements-minimal.txt && \
echo "gunicorn" >> requirements-minimal.txt
# 安装Python依赖使用最小化依赖opencv使用headless版本
RUN pip install --no-cache-dir -r requirements-minimal.txt
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements-minimal.txt && \
python -m pip install --force-reinstall gunicorn && \
python -c "import gunicorn; print(f'Gunicorn version: {gunicorn.__version__}')" && \
python -m gunicorn --version || echo "Gunicorn installed, using python -m gunicorn"
# 复制应用代码
COPY . .
@@ -59,5 +63,6 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:5000/health').read()" || exit 1
# 使用gunicorn启动应用小内存配置单worker减少内存占用
CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--workers", "1", "--threads", "2", "--timeout", "120", "--worker-class", "sync", "--max-requests", "1000", "--max-requests-jitter", "100", "--preload", "--access-logfile", "-", "--error-logfile", "-", "web_app:app"]
# 使用 python -m gunicorn 确保可以找到 gunicorn即使可执行文件不在PATH中也能工作
CMD ["python", "-m", "gunicorn", "--bind", "0.0.0.0:5000", "--workers", "1", "--threads", "2", "--timeout", "120", "--worker-class", "sync", "--max-requests", "1000", "--max-requests-jitter", "100", "--preload", "--access-logfile", "-", "--error-logfile", "-", "web_app:app"]