Spaces:
Build error
Build error
File size: 1,924 Bytes
0ca462b 34e2bb9 0ca462b 30085ca 0ca462b eed2c85 0ca462b eed2c85 0ed604b 0ca462b eed2c85 0ed604b eed2c85 0ca462b | 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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | # --- Build Stage for Rust ---
FROM rust:1.94-slim-bookworm as builder
WORKDIR /app
# Install build dependencies
RUN apt-get update && apt-get install -y \
pkg-config \
libssl-dev \
g++ \
&& rm -rf /var/lib/apt/lists/*
# Copy source code
COPY . .
# Build the application with Tor support
RUN cargo build --release --features tor
# --- Runtime Stage ---
FROM python:3.10-slim-bookworm
WORKDIR /app
# Install runtime dependencies
RUN apt-get update && apt-get install -y \
curl \
ca-certificates \
libssl3 \
tor \
netcat-openbsd \
&& rm -rf /var/lib/apt/lists/*
# Create a non-root user for Hugging Face Spaces
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
# Set up directories
WORKDIR /home/user/app
# Copy Rust binary
COPY --from=builder /app/target/release/intent-forge-v2 /home/user/app/intentforge
# Copy Python microservice
COPY services/query_layer /home/user/app/services/query_layer
# Install Python dependencies
RUN pip install --no-cache-dir -r /home/user/app/services/query_layer/requirements.txt
# Copy configuration files
COPY config.yaml sources.yaml /home/user/app/
# Create entrypoint script
USER root
RUN echo '#!/bin/bash\n\
# Start Tor daemon\n\
mkdir -p /tmp/tor /tmp/tor-data\n\
# Create a dummy torrc if it doesn't exist to satisfy the -f flag\n\
touch /tmp/tor/torrc\n\
tor -f /tmp/tor/torrc --allow-missing-torrc --SocksPort 9050 --DataDirectory /tmp/tor-data &\n\
sleep 5\n\
\n\
# Start Python Query Layer in background\n\
cd /home/user/app/services/query_layer && python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 &\n\
\n\
# Start Rust Core (Binding to 7860 for HF Spaces)\n\
export API_PORT=7860\n\
cd /home/user/app && ./intentforge\n\
' > /entrypoint.sh && chmod +x /entrypoint.sh
USER user
# Hugging Face Spaces use port 7860 by default
EXPOSE 7860
ENTRYPOINT ["/entrypoint.sh"]
|