| # 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 \ | |
| git \ | |
| build-essential && \ | |
| apt-get clean && \ | |
| rm -rf /var/lib/apt/lists/* | |
| # Generate Tor control password hash | |
| RUN tor --hash-password torpass | grep "^16:" > /tmp/torpass.hash | |
| # Write Tor configuration | |
| RUN echo "SocksPort 9050 IsolateSOCKSAuth\n\ | |
| ControlPort 9051\n\ | |
| CookieAuthentication 0\n\ | |
| HashedControlPassword $(cat /tmp/torpass.hash)\n\ | |
| NewCircuitPeriod 15\n" > /etc/tor/torrc | |
| # Copy entire project | |
| COPY . . | |
| # Make start script executable | |
| RUN chmod +x start.sh | |
| # Expose API port | |
| EXPOSE 7860 | |
| # Run start script (tor + app inside script) | |
| CMD ["./start.sh"] | |