Spaces:
Paused
Paused
| # 使用官方的 Python 基础镜像 | |
| FROM python:3.12.2 | |
| # 设置构建参数和环境变量 | |
| ARG NAME="default_name" | |
| ENV NAME=${NAME} | |
| # 设置工作目录 | |
| WORKDIR /app | |
| # 复制应用程序文件 | |
| COPY app.py requirements.txt /app/ | |
| # 安装 Python 依赖 | |
| RUN apt-get update && apt-get install -y libgl1-mesa-glx | |
| # 安装应用依赖 | |
| RUN pip install --upgrade opencv-python | |
| # RUN pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir -r requirements.txt | |
| RUN pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --no-cache-dir | |
| # 暴露端口 | |
| EXPOSE 8090 | |
| # 健康检查(可选,根据应用程序情况调整) | |
| # HEALTHCHECK --interval=30s --timeout=10s --retries=3 CMD curl -f http://localhost:8090/health || exit 1 | |
| # 设置容器启动命令 | |
| CMD ["python", "-u", "app.py"] | |