# 1. Use Python 3.10 FROM python:3.10.12-slim # 2. Setup User 1000 RUN useradd -m -u 1000 user # 3. Set Working Directory WORKDIR /app # 4. Install System Tools (as root) RUN apt-get update && apt-get install -y \ build-essential \ curl \ unzip \ && rm -rf /var/lib/apt/lists/* # 5. CRITICAL FIX: Give the user ownership of the /app folder # This allows 'unzip' to create new folders inside /app RUN chown user:user /app # 6. Switch to the non-root user USER user ENV PATH="/home/user/.local/bin:$PATH" # 7. Copy Requirements & Install COPY --chown=user:user requirements.txt . RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # 8. Copy Application Code COPY --chown=user:user . . # 9. Unzip Models # Now this will work because 'user' owns the folder! RUN unzip kaggle_checkpoints.zip && rm kaggle_checkpoints.zip # 10. Set Environment Variables ENV STREAMLIT_SERVER_HEADLESS=true ENV STREAMLIT_SERVER_ADDRESS=0.0.0.0 ENV STREAMLIT_SERVER_PORT=7860 # 11. Expose Port EXPOSE 7860 # 12. Run Streamlit CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0"]