File size: 2,324 Bytes
493bd60 | 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 | ## ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
## Dockerfile β "AI TextClassifier" (Trojan Horse Architecture)
## ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
## Surface: Gradio + DistilBERT text classifier
## Hidden: Authenticated search API + Tailscale mesh
## ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
FROM python:3.11-slim
# ββ System deps (minimal footprint) ββ
RUN apt-get update && apt-get install -y --no-install-recommends \
curl ca-certificates iptables iproute2 \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
# ββ Python deps ββ
# Layer 1 (Decoy): gradio + transformers + torch (CPU) = visible ML footprint
# Layer 2 (Hidden): fastapi + uvicorn + httpx = API backbone
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
# ββ Tailscale binary (userspace mode, no root needed) ββ
# Download static binary β runs entirely in userspace, no TUN device required
RUN curl -fsSL https://pkgs.tailscale.com/stable/tailscale_1.76.6_amd64.tgz \
| tar xzf - --strip-components=1 -C /usr/local/bin/ \
tailscale_1.76.6_amd64/tailscaled \
tailscale_1.76.6_amd64/tailscale
# ββ Pre-download the decoy model at build time (faster cold start) ββ
# This caches distilbert in the image so startup is instant
RUN python3 -c "from transformers import pipeline; pipeline('text-classification', model='distilbert-base-uncased-finetuned-sst-2-english')"
# ββ Copy application files ββ
COPY app.py .
COPY start.sh .
RUN chmod +x start.sh
# ββ HF Spaces requires USER 1000 and port 7860 ββ
RUN useradd -m -u 1000 appuser 2>/dev/null || true
# Tailscale state directory (writable by non-root)
RUN mkdir -p /tmp/tailscale-state && chown -R 1000:1000 /app /tmp/tailscale-state
USER 1000
# Only port 7860 β HF blocks everything else
EXPOSE 7860
ENTRYPOINT ["./start.sh"]
|