Update Dockerfile
Browse files1 unmodified line23455678891011121213141415161719181920212223242 unmodified lines27282928293031323330313233343536353738394041414242431 unmodified line
WORKDIR /app
# 系统依赖:删除 software-properties-common;加上 --no-install-recommends 精简镜像RUN apt-get update && apt-get install -y \RUN apt-get update && apt-get install -y --no-install-recommends \ build-essential \ curl \ software-properties-common \ git \ && rm -rf /var/lib/apt/lists/*
# 复制需求文件和应用代码# 先复制 requirements 以利用缓存层COPY requirements.txt ./COPY app.py ./
# 安装 Python 依赖RUN pip3 install --no-cache-dir -r requirements.txt
# 创建所有可能需要的目录并给予完全权限# 再复制应用代码COPY app.py ./
# 创建目录(你原先就有),保持不改你的路径与权限设定RUN mkdir -p /tmp/.streamlit && chmod 777 /tmp/.streamlit && \ mkdir -p /app/.streamlit && chmod 777 /app/.streamlit && \ mkdir -p /.streamlit && chmod 777 /.streamlit && \2 unmodified lines mkdir -p /root/.streamlit && chmod 777 /root/.streamlit && \ chmod 777 /app
# 设置环境变量ENV STREAMLIT_SERVER_HEADLESS=trueENV STREAMLIT_SERVER_ENABLE_CORS=falseENV STREAMLIT_SERVER_PORT=8501ENV STREAMLIT_CONFIG_DIR=/tmp/.streamlitENV STREAMLIT_BROWSER_GATHER_USAGE_STATS=false# 环境变量ENV STREAMLIT_SERVER_HEADLESS=true \ STREAMLIT_SERVER_ENABLE_CORS=false \ STREAMLIT_SERVER_PORT=8501 \ STREAMLIT_CONFIG_DIR=/tmp/.streamlit \ 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"]# 启动CMD ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false", "--server.enableWebsocketCompression=false"]Dockerfile+15-14