Spaces:
Sleeping
Sleeping
File size: 2,041 Bytes
51e54e5 d51faa2 e102d61 d51faa2 f873160 51e54e5 39f0f43 d51faa2 39f0f43 d51faa2 39f0f43 d51faa2 51e54e5 d51faa2 51e54e5 f873160 d51faa2 51e54e5 f873160 d51faa2 51e54e5 d51faa2 f873160 d51faa2 51e54e5 d51faa2 f873160 51e54e5 d51faa2 |
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
FROM python:3.11-slim
WORKDIR /app
# Send caches to /data (persistent & writable on Spaces)
ENV XDG_CACHE_HOME=/data/.cache
ENV HF_HOME=/data/.cache/huggingface
ENV HUGGINGFACE_HUB_CACHE=/data/.cache/huggingface
ENV TRANSFORMERS_CACHE=/data/.cache/huggingface/transformers
ENV STREAMLIT_BROWSER_GATHERUSAGESTATS=false
# Optional: if you want to *disable* Torch Inductor JIT (no C++ compile at runtime)
# ENV TORCHINDUCTOR_DISABLE=1
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY src/ ./src/
# Run as non-root
USER user
# Port & healthcheck expected by the Space
EXPOSE 8501
HEALTHCHECK CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8501/_stcore/health')" || exit 1
# Launch Streamlit
CMD ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
FROM python:3.11-slim
ENV PYTHONDONTWRITEBYTECODE=1
ENV PYTHONUNBUFFERED=1
ENV HOME=/home/user
# Install git so pip can install from GitHub (transformers fork)
RUN apt-get update \
&& apt-get install -y --no-install-recommends git \
&& rm -rf /var/lib/apt/lists/*
# Create non-root user and writable dirs (avoid /.streamlit, /.cache perms)
RUN useradd -m -u 1000 user \
&& mkdir -p /data ${HOME}/.streamlit \
&& chown -R user:user /data ${HOME}
WORKDIR /app
# Send caches to /data (persistent & writable on Spaces)
ENV XDG_CACHE_HOME=/data/.cache
ENV HF_HOME=/data/.cache/huggingface
ENV HUGGINGFACE_HUB_CACHE=/data/.cache/huggingface
ENV TRANSFORMERS_CACHE=/data/.cache/huggingface/transformers
ENV STREAMLIT_BROWSER_GATHERUSAGESTATS=false
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY src/ ./src/
# Run as non-root
USER user
# Port & healthcheck expected by the Space
EXPOSE 8501
HEALTHCHECK CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:8501/_stcore/health')" || exit 1
# Launch Streamlit
CMD ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"] |