FROM python:3.11-slim WORKDIR /app RUN apt-get update && apt-get install -y \ build-essential \ curl \ software-properties-common \ git \ && rm -rf /var/lib/apt/lists/* # Create cache directory and set permissions RUN mkdir -p /app/.cache/torch && \ chmod -R 777 /app/.cache # Set environment variables ENV TORCH_HOME=/app/.cache/torch \ ENABLE_XSRF_PROTECTION=false # Add a non-root user and switch to it RUN useradd -m -u 1000 appuser USER appuser ENV HOME="/home/appuser" WORKDIR $HOME RUN mkdir -p $HOME/.cache/torch && chmod -R 777 $HOME/.cache ENV TORCH_HOME=$HOME/.cache/torch COPY requirements.txt ./ COPY src/ ./src/ COPY data/ ./data/ RUN pip3 install --user -r requirements.txt ENV PATH=$HOME/.local/bin:$PATH EXPOSE 8501 HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]