Spaces:
Sleeping
Sleeping
File size: 1,321 Bytes
fa6a2ef f5ff20f b8533ae f5ff20f b8533ae f5ff20f b8533ae fa6a2ef fbe1270 b8533ae fbe1270 b8533ae fbe1270 499f161 b8533ae fbe1270 b8533ae 499f161 b8533ae f5ff20f b8533ae f5ff20f b8533ae | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | FROM python:3.12-slim
WORKDIR /app
RUN apt-get update && apt-get install -y \
build-essential \
curl \
software-properties-common \
git \
&& rm -rf /var/lib/apt/lists/*
# 复制需求文件和应用代码
COPY requirements.txt ./
COPY app.py ./
# 安装 Python 依赖
RUN pip3 install --no-cache-dir -r requirements.txt
# 创建所有可能需要的目录并给予完全权限
RUN mkdir -p /tmp/.streamlit && chmod 777 /tmp/.streamlit && \
mkdir -p /app/.streamlit && chmod 777 /app/.streamlit && \
mkdir -p /.streamlit && chmod 777 /.streamlit && \
mkdir -p /app/extracted_images && chmod 777 /app/extracted_images && \
mkdir -p /tmp/streamlit_temp && chmod 777 /tmp/streamlit_temp && \
mkdir -p /root/.streamlit && chmod 777 /root/.streamlit && \
chmod 777 /app
# 设置环境变量
ENV STREAMLIT_SERVER_HEADLESS=true
ENV STREAMLIT_SERVER_ENABLE_CORS=false
ENV STREAMLIT_SERVER_PORT=8501
ENV STREAMLIT_CONFIG_DIR=/tmp/.streamlit
ENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false
# 暴露端口
EXPOSE 8501
# 健康检查
HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
# 启动命令
CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false", "--server.enableWebsocketCompression=false"] |