File size: 880 Bytes
fc9e32d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
FROM debian:bullseye-slim

# Install dependencies
RUN apt-get update && apt-get install -y \
    tor \
    python3 \
    python3-pip \
    && rm -rf /var/lib/apt/lists/*

# Install Python dependencies
RUN pip3 install requests requests[socks] fastapi uvicorn

# Create a non-root user for running Tor
RUN useradd -m -s /bin/bash toruser

# Create Tor data directory and set permissions
RUN mkdir -p /var/lib/tor && chown toruser:toruser /var/lib/tor

# Copy custom torrc configuration
COPY torrc /etc/tor/torrc

# Set working directory
WORKDIR /app

# Copy the application script
COPY app.py /app/app.py

# Make the script executable
RUN chmod +x /app/app.py

# Switch to non-root user
USER toruser

# Expose port for FastAPI (Hugging Face Spaces uses 7860)
EXPOSE 7860

# Run Tor in the background and the FastAPI application
CMD tor & uvicorn app:main --host 0.0.0.0 --port 7860