# Use official Python base image with CUDA support FROM nvidia/cuda:12.1.0-runtime-ubuntu22.04 # Set environment variables ENV PYTHONUNBUFFERED=1 \ DEBIAN_FRONTEND=noninteractive \ PIP_NO_CACHE_DIR=1 \ PIP_DISABLE_PIP_VERSION_CHECK=1 \ HF_HOME=/app/.cache/huggingface \ STREAMLIT_SERVER_HEADLESS=true \ STREAMLIT_SERVER_FILE_WATCHER_TYPE=none \ STREAMLIT_BROWSER_GATHER_USAGE_STATS=false \ STREAMLIT_CONFIG_DIR=/app/.streamlit \ TRITON_CACHE_DIR=/app/.triton \ HOME=/app # Install system dependencies including Python 3.10 RUN apt-get update && apt-get install -y \ python3.10 \ python3-pip \ git \ wget \ curl \ && rm -rf /var/lib/apt/lists/* # Create symlink for python3 if needed RUN ln -sf /usr/bin/python3.10 /usr/bin/python3 # Set working directory WORKDIR /app # Copy requirements first for better caching COPY requirements.txt . # Install Python dependencies RUN pip3 install --no-cache-dir -r requirements.txt # Install playwright browsers RUN playwright install --with-deps chromium # Copy agent code and Streamlit app COPY agent_azure_vlm_tools.py . COPY streamlit_app.py . COPY .streamlit/config.toml /app/.streamlit/ # Note: .env not copied - use HF Spaces secrets instead # Create cache and output directories with proper permissions RUN mkdir -p Outputs /app/.cache/huggingface/hub /app/.streamlit /app/.triton && \ chmod -R 777 /app/.cache /app/Outputs /app/.streamlit /app/.triton # Expose port (Streamlit default) EXPOSE 7860 # Health check HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \ CMD curl -f http://localhost:7860/_stcore/health || exit 1 # Run Streamlit CMD ["streamlit", "run", "streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.headless=true"]