intentforge / Dockerfile
Likhith Sai Seemala
fix: add g++ to builder stage to resolve libstdc++ linker error
30085ca
Raw History Blame Contribute Delete
1.92 kB
# --- 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"]