File size: 2,908 Bytes
891669b
d13b6bd
 
 
 
 
 
 
 
891669b
d13b6bd
891669b
 
 
 
d13b6bd
fe0d120
 
891669b
adbf39e
d13b6bd
99933af
7f7ea4a
fe0d120
d13b6bd
 
 
 
 
fe0d120
d13b6bd
fe0d120
 
d13b6bd
 
 
 
 
 
 
e9073c0
891669b
 
 
fe0d120
d13b6bd
 
 
e378396
 
e9073c0
891669b
e378396
 
 
fe0d120
e378396
fe0d120
 
 
e9073c0
 
 
 
891669b
 
 
 
 
a11eff2
486b786
eab1ab3
 
2dcd6e8
792eca8
9544d64
d83cac6
327355f
081db53
891669b
 
 
fe0d120
d13b6bd
 
 
e378396
891669b
fe0d120
d13b6bd
fe0d120
 
d13b6bd
6973a2a
 
d13b6bd
6973a2a
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Dockerfile for TQB Worker on HuggingFace Spaces
#
# CHANGELOG [2025-01-30 - Josh]
# REBUILD: Updated to Gradio 5.0+ for type="messages" support
#
# CHANGELOG [2025-01-31 - Claude]
# FIXED: Permissions for HF Spaces runtime user (UID 1000).
#
# CHANGELOG [2025-01-31 - Claude + Gemini]
# FIXED: /.cache PermissionError for embedding model download.
#
# CHANGELOG [2026-03-29 - Hammer/TQB — Block G Assembly]
# UPDATED: Added tools/ directory, new module files, anthropic SDK.
# Swapped from Kimi K2.5 to Claude. Added ANTHROPIC_API_KEY and CLAUDE_MODEL_ID env vars.
# Added /data/ persistent directory for worker NeuroGraph.

FROM python:3.11-slim

# CACHE BUSTER: Update this date to invalidate Docker cache
ENV REBUILD_DATE=2026-04-05-chassis-dialin

WORKDIR /app

# Install system dependencies
RUN apt-get update && apt-get install -y \
    git \
    build-essential \
    curl \
    && rm -rf /var/lib/apt/lists/*

# Copy requirements first (for Docker layer caching)
COPY requirements.txt .

# Install Python dependencies
RUN pip uninstall -y gradio gradio-client 2>/dev/null; \
    pip install --no-cache-dir -r requirements.txt

# Create all directories the app needs to write to at runtime
RUN mkdir -p /workspace/e-t-systems \
             /tmp/.cache/huggingface \
             /tmp/.cache/torch \
             /tmp/.neurograph/checkpoints \
             /data/neurograph_worker/checkpoints \
             /data/audit

# =============================================================================
# ENVIRONMENT VARIABLES
# =============================================================================
ENV HF_HOME=/tmp/.cache/huggingface
ENV XDG_CACHE_HOME=/tmp/.cache
ENV TORCH_HOME=/tmp/.cache/torch
ENV NEUROGRAPH_WORKSPACE_DIR=/data/neurograph_worker
ENV HOME=/tmp
ENV PYTHONUNBUFFERED=1
ENV REPO_PATH=/workspace/e-t-systems

# Copy application files
COPY recursive_context.py .
COPY app.py .
COPY entrypoint.sh .
COPY neuro_foundation.py .
COPY universal_ingestor.py .
COPY openclaw_hook.py .
COPY neurograph_migrate.py .
COPY policy_engine.py .
COPY model_client.py .
COPY system_prompt.py .
COPY tool_definitions.py .
COPY worker_ng.py .
COPY surface_resolver.py .
COPY ng_embed.py .
COPY work_block_schema.py .
COPY spec_executor.py .
COPY persona_client.py .
COPY report_evaluator.py .
COPY risk_authority.py .
COPY spec_generator.py .
COPY orchestrator.py .
COPY ng_topology_sync.py .

# Copy tools directory
COPY tools/ ./tools/

# =============================================================================
# PERMISSIONS FOR HF SPACES (UID 1000)
# =============================================================================
RUN chmod +x entrypoint.sh && \
    chown -R 1000:1000 /app /workspace /tmp/.cache /tmp/.neurograph /data

# Expose Gradio port (HF Spaces standard)
EXPOSE 7860

# Switch to non-root user
USER 1000

# Launch via entrypoint script
CMD ["./entrypoint.sh"]