levalencia commited on
Commit
9626485
·
1 Parent(s): 479ced5

Refactor Dockerfile to create Streamlit configuration directly

Browse files

- Removed the copy of the .streamlit directory and replaced it with a RUN command to generate the Streamlit config file within the Dockerfile.
- Configured various Streamlit settings for production use, including server settings and theme customization.

Files changed (2) hide show
  1. Dockerfile +21 -1
  2. TROUBLESHOOTING.md +71 -0
Dockerfile CHANGED
@@ -16,7 +16,27 @@ RUN mkdir -p /app/.streamlit /tmp/docling_temp && \
16
 
17
  COPY requirements.txt ./
18
  COPY src/ ./src/
19
- COPY .streamlit/ ./.streamlit/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  RUN pip3 install -r requirements.txt
22
 
 
16
 
17
  COPY requirements.txt ./
18
  COPY src/ ./src/
19
+
20
+ # Create Streamlit config directly in Dockerfile to avoid copy issues
21
+ RUN echo '[global]' > /app/.streamlit/config.toml && \
22
+ echo 'developmentMode = false' >> /app/.streamlit/config.toml && \
23
+ echo '' >> /app/.streamlit/config.toml && \
24
+ echo '[server]' >> /app/.streamlit/config.toml && \
25
+ echo 'fileWatcherType = "none"' >> /app/.streamlit/config.toml && \
26
+ echo 'headless = true' >> /app/.streamlit/config.toml && \
27
+ echo 'enableCORS = false' >> /app/.streamlit/config.toml && \
28
+ echo 'enableXsrfProtection = false' >> /app/.streamlit/config.toml && \
29
+ echo '' >> /app/.streamlit/config.toml && \
30
+ echo '[browser]' >> /app/.streamlit/config.toml && \
31
+ echo 'gatherUsageStats = false' >> /app/.streamlit/config.toml && \
32
+ echo 'serverAddress = "0.0.0.0"' >> /app/.streamlit/config.toml && \
33
+ echo 'serverPort = 8501' >> /app/.streamlit/config.toml && \
34
+ echo '' >> /app/.streamlit/config.toml && \
35
+ echo '[theme]' >> /app/.streamlit/config.toml && \
36
+ echo 'primaryColor = "#1f77b4"' >> /app/.streamlit/config.toml && \
37
+ echo 'backgroundColor = "#ffffff"' >> /app/.streamlit/config.toml && \
38
+ echo 'secondaryBackgroundColor = "#f0f2f6"' >> /app/.streamlit/config.toml && \
39
+ echo 'textColor = "#262730"' >> /app/.streamlit/config.toml
40
 
41
  RUN pip3 install -r requirements.txt
42
 
TROUBLESHOOTING.md ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Troubleshooting Guide
2
+
3
+ ## Hugging Face Deployment Issues
4
+
5
+ ### Permission Errors
6
+
7
+ If you encounter permission errors like:
8
+ ```
9
+ PermissionError: [Errno 13] Permission denied: 'temp_files'
10
+ ```
11
+
12
+ The app has been updated to handle these automatically by:
13
+ 1. Using system temp directories (`/tmp/docling_temp`)
14
+ 2. Falling back to current working directory
15
+ 3. Using current directory as last resort
16
+
17
+ ### Streamlit Configuration Issues
18
+
19
+ If you see errors related to Streamlit configuration:
20
+ ```
21
+ PermissionError: [Errno 13] Permission denied: '/.streamlit'
22
+ ```
23
+
24
+ The app now:
25
+ 1. Disables usage statistics collection
26
+ 2. Uses headless mode
27
+ 3. Disables file watcher
28
+ 4. Uses proper configuration files
29
+
30
+ ### Testing the Environment
31
+
32
+ You can test if the environment is working correctly by running:
33
+
34
+ ```bash
35
+ python test_permissions.py
36
+ ```
37
+
38
+ This will check:
39
+ - Directory creation permissions
40
+ - File write permissions
41
+ - Environment variable configuration
42
+ - Current directory access
43
+
44
+ ### Common Solutions
45
+
46
+ 1. **Clear all data**: Use the "Clear All Data" button in the app
47
+ 2. **Restart the app**: Sometimes a simple restart fixes permission issues
48
+ 3. **Check logs**: Look for detailed error messages in the app logs
49
+
50
+ ### Environment Variables
51
+
52
+ The app automatically sets these environment variables:
53
+ - `STREAMLIT_SERVER_FILE_WATCHER_TYPE=none`
54
+ - `STREAMLIT_SERVER_HEADLESS=true`
55
+ - `STREAMLIT_BROWSER_GATHER_USAGE_STATS=false`
56
+ - `STREAMLIT_SERVER_ENABLE_CORS=false`
57
+ - `STREAMLIT_SERVER_ENABLE_XSRF_PROTECTION=false`
58
+
59
+ ### File Structure
60
+
61
+ The app creates these directories:
62
+ - `.streamlit/` - Streamlit configuration
63
+ - `temp_files/` or `/tmp/docling_temp/` - Temporary files
64
+ - `src/` - Application source code
65
+
66
+ ### Docker Configuration
67
+
68
+ The Dockerfile has been updated to:
69
+ - Create necessary directories with proper permissions
70
+ - Copy Streamlit configuration files
71
+ - Set up proper environment variables