# Use Python 3.9 slim image for better compatibility FROM python:3.9-slim # Set working directory WORKDIR /app # Set environment variables ENV PYTHONPATH=/app ENV PYTHONUNBUFFERED=1 ENV DEBIAN_FRONTEND=noninteractive # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ curl \ software-properties-common \ git \ libgl1-mesa-glx \ libglib2.0-0 \ libsm6 \ libxext6 \ libxrender-dev \ libgomp1 \ && rm -rf /var/lib/apt/lists/* # Copy requirements first for better caching COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir --upgrade pip && \ pip install --no-cache-dir -r requirements.txt # Copy the entire project COPY . . # Create necessary directories RUN mkdir -p /app/data/image_data /app/data/videos_data # Download models (if you have pretrained models) # You can uncomment these lines if you want to download models from a URL # RUN wget -O hybrid_deepfake_model.h5 "YOUR_MODEL_URL" || echo "Model download skipped" # Expose ports for both services EXPOSE 7860 8501 # Create a startup script RUN echo '#!/bin/bash\n\ echo "Starting FastAPI server..."\n\ python app/main.py &\n\ sleep 10\n\ echo "Starting Streamlit app..."\n\ streamlit run src/streamlit_app.py --server.port=8501 --server.address=0.0.0.0\n' > /app/start.sh && chmod +x /app/start.sh # For Hugging Face Spaces, we'll use the Streamlit app as the main entrypoint CMD ["streamlit", "run", "src/streamlit_app.py", "--server.port=7860", "--server.address=0.0.0.0"]