mirror of
https://git.oceanpay.cc/danial/kami_ctrip.git
synced 2025-12-18 12:54:41 +00:00
Introduce a health check endpoint `/health` to monitor the application's status, including uptime, memory usage, CPU percentage, and thread count. Add `psutil` dependency to gather system metrics. Also, include `curl` in Dockerfile for health check functionality and update the health check configuration in Dockerfile.
41 lines
1.3 KiB
Docker
41 lines
1.3 KiB
Docker
# 基于 Python 3.8.6 镜像
|
|
FROM python:3.8.6
|
|
|
|
WORKDIR /app
|
|
|
|
# 设置工作目录
|
|
ENV FLASK_APP=app.py
|
|
# 复制项目
|
|
ADD . /app
|
|
|
|
# 修改apt-get源地址为阿里云镜像
|
|
RUN echo "" > /etc/apt/sources.list && \
|
|
echo "deb http://mirrors.aliyun.com/debian buster main" >> /etc/apt/sources.list && \
|
|
echo "deb http://mirrors.aliyun.com/debian-security buster/updates main" >> /etc/apt/sources.list && \
|
|
echo "deb http://mirrors.aliyun.com/debian buster-updates main" >> /etc/apt/sources.list
|
|
|
|
# 安装cv2依赖和其他依赖
|
|
RUN apt-get update && apt-get install -y libgl1-mesa-glx libglib2.0-0 curl
|
|
|
|
# 下载并安装 Node.js
|
|
RUN wget https://nodejs.org/dist/v16.13.0/node-v16.13.0-linux-x64.tar.gz && \
|
|
tar -xvf node-v16.13.0-linux-x64.tar.gz && \
|
|
mv node-v16.13.0-linux-x64 /usr/local/nodejs && \
|
|
ln -s /usr/local/nodejs/bin/node /usr/local/bin && \
|
|
ln -s /usr/local/nodejs/bin/npm /usr/local/bin && \
|
|
rm node-v16.13.0-linux-x64.tar.gz
|
|
|
|
# python环境包
|
|
RUN pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple gunicorn gevent
|
|
RUN pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
|
|
|
|
# 暴露容器端口
|
|
EXPOSE 5001
|
|
|
|
# 添加健康检查
|
|
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
|
CMD curl -f http://localhost:5001/health || exit 1
|
|
|
|
# 运行应用
|
|
CMD ["gunicorn", "-c", "gun.conf", "app:app"]
|