# Use slim python base image FROM python:3.11-slim # Set working directory WORKDIR /app # Install system dependencies + Tor RUN apt-get update && \ apt-get install -y --no-install-recommends \ tor \ build-essential && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* # Generate Tor control password hash (SAFE & CORRECT) RUN tor --hash-password torpass | grep "^16:" > /tmp/torpass.hash # Write Tor configuration RUN echo "SocksPort 9050\n\ ControlPort 9051\n\ CookieAuthentication 0\n\ HashedControlPassword $(cat /tmp/torpass.hash)\n\ NewCircuitPeriod 15\n" > /etc/tor/torrc # Copy requirements first (better caching) COPY requirements.txt . # Install Python dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy project files COPY . . # Expose API port EXPOSE 7860 # Start Tor in background, then FastAPI CMD tor & uvicorn main:app --host 0.0.0.0 --port 7860