Executor-Tyrant-Framework commited on
Commit
6973a2a
·
unverified ·
1 Parent(s): 1b1a732

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +49 -8
Dockerfile CHANGED
@@ -4,19 +4,32 @@
4
  # REBUILD: Updated to Gradio 5.0+ for type="messages" support
5
  # Added translation layer for Kimi K2.5 tool calling
6
  # Added multimodal file upload support
7
- #
 
 
 
 
 
 
 
 
 
 
 
 
8
  # FEATURES:
9
  # - Python 3.11 for Gradio
10
  # - Gradio 5.0+ for modern chat interface
11
  # - ChromaDB for vector search
12
  # - Git for repo cloning
13
  # - Optimized layer caching
 
14
 
15
  FROM python:3.11-slim
16
 
17
- # CACHE BUSTER: Force rebuild for Gradio 5.0+ [2025-01-30]
18
- # This MUST be before COPY requirements.txt to invalidate cache
19
- ENV REBUILD_DATE=2025-01-30-v3
20
 
21
  # Set working directory
22
  WORKDIR /app
@@ -32,7 +45,7 @@ RUN apt-get update && apt-get install -y \
32
  COPY requirements.txt .
33
 
34
  # FORCE CLEAN INSTALL: Uninstall any cached Gradio, then install fresh
35
- RUN pip uninstall -y gradio gradio-client && \
36
  pip install --no-cache-dir -r requirements.txt
37
 
38
  # Create workspace directory for repository
@@ -56,8 +69,25 @@ COPY entrypoint.sh .
56
  # Make entrypoint executable
57
  RUN chmod +x entrypoint.sh
58
 
59
- # Create directory for ChromaDB persistence
60
- RUN mkdir -p /workspace/chroma_db
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61
 
62
  # Expose port for Gradio (HF Spaces uses 7860)
63
  EXPOSE 7860
@@ -70,5 +100,16 @@ ENV REPO_PATH=/workspace/e-t-systems
70
  HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
71
  CMD curl -f http://localhost:7860/ || exit 1
72
 
 
 
 
 
 
 
 
 
 
 
 
73
  # Run via entrypoint script (handles repo cloning at runtime)
74
- CMD ["./entrypoint.sh"]
 
4
  # REBUILD: Updated to Gradio 5.0+ for type="messages" support
5
  # Added translation layer for Kimi K2.5 tool calling
6
  # Added multimodal file upload support
7
+ #
8
+ # CHANGELOG [2025-01-31 - Claude]
9
+ # FIXED: Permissions for HF Spaces runtime user (UID 1000).
10
+ # PROBLEM: HF Spaces run containers as user 1000, not root. Directories
11
+ # created during build (as root) weren't writable at runtime, causing
12
+ # ChromaDB to silently fail when trying to create SQLite files.
13
+ # FIX: chown all writable directories to 1000:1000, then switch to USER 1000.
14
+ #
15
+ # ALSO: Added /data directory for HF persistent storage.
16
+ # /data is the ONLY path that survives container restarts on HF Spaces.
17
+ # Must enable "Persistent Storage" in Space Settings for /data to exist.
18
+ # Falls back to /workspace (ephemeral) if /data isn't available.
19
+ #
20
  # FEATURES:
21
  # - Python 3.11 for Gradio
22
  # - Gradio 5.0+ for modern chat interface
23
  # - ChromaDB for vector search
24
  # - Git for repo cloning
25
  # - Optimized layer caching
26
+ # - Correct permissions for HF Spaces (UID 1000)
27
 
28
  FROM python:3.11-slim
29
 
30
+ # CACHE BUSTER: Force rebuild when dependencies change
31
+ # Update this date to invalidate Docker cache for everything below
32
+ ENV REBUILD_DATE=2025-01-31-v1
33
 
34
  # Set working directory
35
  WORKDIR /app
 
45
  COPY requirements.txt .
46
 
47
  # FORCE CLEAN INSTALL: Uninstall any cached Gradio, then install fresh
48
+ RUN pip uninstall -y gradio gradio-client 2>/dev/null; \
49
  pip install --no-cache-dir -r requirements.txt
50
 
51
  # Create workspace directory for repository
 
69
  # Make entrypoint executable
70
  RUN chmod +x entrypoint.sh
71
 
72
+ # =============================================================================
73
+ # PERMISSIONS FIX FOR HF SPACES
74
+ # =============================================================================
75
+ # CHANGELOG [2025-01-31 - Claude]
76
+ # HF Spaces run as UID 1000, not root. All directories that the app needs
77
+ # to write to must be owned by 1000:1000, otherwise ChromaDB, conversation
78
+ # saves, and file downloads will silently fail.
79
+ #
80
+ # /workspace - ephemeral storage (wiped on restart, but works within session)
81
+ # /workspace/chroma_db - ChromaDB fallback if /data isn't available
82
+ # /data - HF persistent storage (survives restarts, created by HF at runtime)
83
+ # NOTE: /data may not exist at build time. We create it here so the chown
84
+ # works, but HF may mount over it at runtime. That's fine - HF sets correct
85
+ # permissions on their mount. This is belt-and-suspenders.
86
+ # /tmp - needed for temporary files during cloud backup
87
+ # /app - the application directory itself (for any runtime-generated files)
88
+ # =============================================================================
89
+ RUN mkdir -p /workspace/chroma_db /data/chroma_db /tmp && \
90
+ chown -R 1000:1000 /workspace /data /tmp /app
91
 
92
  # Expose port for Gradio (HF Spaces uses 7860)
93
  EXPOSE 7860
 
100
  HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
101
  CMD curl -f http://localhost:7860/ || exit 1
102
 
103
+ # =============================================================================
104
+ # SWITCH TO NON-ROOT USER
105
+ # =============================================================================
106
+ # CHANGELOG [2025-01-31 - Claude]
107
+ # HF Spaces expect the container to run as UID 1000. Setting this explicitly
108
+ # ensures consistent behavior between local testing and deployed Spaces.
109
+ # Without this, the process runs as root during build but HF forces UID 1000
110
+ # at runtime, causing permission mismatches on files created during build.
111
+ # =============================================================================
112
+ USER 1000
113
+
114
  # Run via entrypoint script (handles repo cloning at runtime)
115
+ CMD ["./entrypoint.sh"]