Spaces:
Sleeping
Sleeping
| FROM python:3.9-slim | |
| ARG HF_TOKEN | |
| ENV HF_TOKEN=${HF_TOKEN} | |
| WORKDIR /app | |
| # System dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| curl \ | |
| git \ | |
| git-lfs \ | |
| cmake \ | |
| python3-dev \ | |
| wget \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Install Python dependencies (including huggingface_hub) | |
| COPY requirements.txt ./ | |
| RUN pip3 install --no-cache-dir -r requirements.txt huggingface_hub | |
| # Download model securely using huggingface_hub and HF_TOKEN | |
| COPY model/download_model.py model/download_model.py | |
| # RUN python3 model/download_model.py | |
| # Copy rest of app | |
| COPY . ./ | |
| # Streamlit port | |
| EXPOSE 8501 | |
| # Healthcheck | |
| HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health | |
| # Writable Streamlit config | |
| RUN mkdir -p /tmp/.streamlit /.streamlit && chmod -R 777 /.streamlit | |
| ENV STREAMLIT_HOME=/tmp/.streamlit | |
| ENV XDG_CONFIG_HOME=/tmp/.streamlit | |
| ENV BROWSER_GATHER_USAGE_STATS=false | |
| RUN echo "[browser]\ngatherUsageStats = false" > /tmp/.streamlit/config.toml | |
| ENV MODEL_PATH=/tmp/models/TinyLlama-1.1B-Chat-v1.0.Q4_K_M.gguf | |
| # Launch Streamlit | |
| ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0"] | |