rasmodev's picture
Update Dockerfile
6c91161 verified
FROM python:3.10-slim
RUN apt-get update && apt-get install -y \
build-essential \
curl \
libgl1 \
libglib2.0-0 \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -m -u 1000 appuser
WORKDIR /app
# Download and install torch CPU wheel directly
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir \
"torch==2.2.2" \
"torchvision==0.17.2" \
--find-links https://download.pytorch.org/whl/cpu/torch_stable.html
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN mkdir -p /app/.streamlit && printf '[server]\nmaxUploadSize = 200\nenableCORS = false\nenableXsrfProtection = false\nport = 7860\n\n[browser]\ngatherUsageStats = false\n' > /app/.streamlit/config.toml
RUN chown -R appuser:appuser /app
USER appuser
ENV HF_HOME=/app/.cache/huggingface
ENV TRANSFORMERS_CACHE=/app/.cache/huggingface
EXPOSE 7860
CMD ["streamlit", "run", "app.py", \
"--server.port=7860", \
"--server.address=0.0.0.0", \
"--server.headless=true", \
"--server.maxUploadSize=200", \
"--server.enableCORS=false", \
"--server.enableXsrfProtection=false", \
"--browser.gatherUsageStats=false"]