Princess3 commited on
Commit
21dc4a6
Β·
verified Β·
1 Parent(s): 861c201

Delete README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -305
README.md DELETED
@@ -1,305 +0,0 @@
1
- # Docker Setup for NZ Legislation Loophole Analysis Streamlit App
2
-
3
- This guide explains how to run the NZ Legislation Loophole Analysis Streamlit App using Docker.
4
-
5
- ## πŸ“‹ Prerequisites
6
-
7
- - Docker installed on your system
8
- - Docker Compose (recommended for easier management)
9
- - At least 4GB of available RAM (8GB recommended for optimal performance)
10
-
11
- ## πŸš€ Quick Start
12
-
13
- ### Method 1: Using Docker Compose (Recommended)
14
-
15
- ```bash
16
- # Clone or navigate to the project directory
17
- cd /path/to/nz-legislation-analyzer
18
-
19
- # Build and run the application
20
- docker-compose up --build
21
-
22
- # Or run in detached mode
23
- docker-compose up -d --build
24
- ```
25
-
26
- The application will be available at: **http://localhost:8501**
27
-
28
- ### Method 2: Using Docker Directly
29
-
30
- ```bash
31
- # Build the Docker image
32
- docker build -t nz-legislation-analyzer .
33
-
34
- # Run the container
35
- docker run -p 8501:8501 \
36
- -v $(pwd)/streamlit_app/cache:/app/streamlit_app/cache \
37
- -v $(pwd)/streamlit_app/config:/app/streamlit_app/config \
38
- -v $(pwd)/streamlit_app/datasets:/app/streamlit_app/datasets \
39
- -v $(pwd)/nz-legislation.txt:/app/nz-legislation.txt:ro \
40
- nz-legislation-analyzer
41
- ```
42
-
43
- ## πŸ“ Directory Structure
44
-
45
- When using Docker, the following directories are created and can be persisted:
46
-
47
- ```
48
- πŸ“ streamlit_app/
49
- β”œβ”€β”€ 🧠 cache/ # Persistent cache for processed chunks
50
- β”œβ”€β”€ βš™οΈ config/ # Application configuration files
51
- β”œβ”€β”€ πŸ“Š datasets/ # Generated datasets and results
52
- β”œβ”€β”€ πŸ“ logs/ # Application logs
53
- └── πŸ“€ uploads/ # Uploaded files (if any)
54
- ```
55
-
56
- ## πŸ› οΈ Configuration
57
-
58
- ### Environment Variables
59
-
60
- | Variable | Default | Description |
61
- |----------|---------|-------------|
62
- | `STREAMLIT_SERVER_HEADLESS` | `true` | Run in headless mode |
63
- | `STREAMLIT_SERVER_PORT` | `8501` | Streamlit server port |
64
- | `STREAMLIT_SERVER_ADDRESS` | `0.0.0.0` | Server bind address |
65
-
66
- ### Volume Mounts
67
-
68
- The Docker setup includes the following volume mounts for data persistence:
69
-
70
- - `./streamlit_app/cache:/app/streamlit_app/cache` - Cache persistence
71
- - `./streamlit_app/config:/app/streamlit_app/config` - Configuration files
72
- - `./streamlit_app/datasets:/app/streamlit_app/datasets` - Generated datasets
73
- - `./streamlit_app/logs:/app/streamlit_app/logs` - Application logs
74
- - `./nz-legislation.txt:/app/nz-legislation.txt:ro` - Input data (read-only)
75
-
76
- ## πŸ”§ Docker Commands
77
-
78
- ### Building the Image
79
-
80
- ```bash
81
- # Build with no cache
82
- docker build --no-cache -t nz-legislation-analyzer .
83
-
84
- # Build with specific Dockerfile
85
- docker build -f Dockerfile -t nz-legislation-analyzer .
86
- ```
87
-
88
- ### Running the Container
89
-
90
- ```bash
91
- # Interactive mode
92
- docker run -it --rm -p 8501:8501 nz-legislation-analyzer
93
-
94
- # Background mode
95
- docker run -d -p 8501:8501 nz-legislation-analyzer
96
-
97
- # With custom environment variables
98
- docker run -p 8501:8501 \
99
- -e STREAMLIT_SERVER_PORT=8502 \
100
- nz-legislation-analyzer
101
- ```
102
-
103
- ### Docker Compose Commands
104
-
105
- ```bash
106
- # Start services
107
- docker-compose up
108
-
109
- # Start in background
110
- docker-compose up -d
111
-
112
- # Stop services
113
- docker-compose down
114
-
115
- # Rebuild and start
116
- docker-compose up --build
117
-
118
- # View logs
119
- docker-compose logs -f
120
-
121
- # Scale services (if needed)
122
- docker-compose up -d --scale nz-legislation-analyzer=2
123
- ```
124
-
125
- ## πŸ“Š Monitoring and Logs
126
-
127
- ### Viewing Logs
128
-
129
- ```bash
130
- # Docker Compose logs
131
- docker-compose logs -f nz-legislation-analyzer
132
-
133
- # Docker logs
134
- docker logs -f <container_id>
135
-
136
- # Follow logs in real-time
137
- docker-compose logs -f --tail=100
138
- ```
139
-
140
- ### Health Checks
141
-
142
- The Docker Compose setup includes health checks that monitor the Streamlit application:
143
-
144
- ```yaml
145
- healthcheck:
146
- test: ["CMD", "curl", "-f", "http://localhost:8501/healthz"]
147
- interval: 30s
148
- timeout: 10s
149
- retries: 3
150
- start_period: 40s
151
- ```
152
-
153
- ## πŸ” Troubleshooting
154
-
155
- ### Common Issues
156
-
157
- 1. **Port Already in Use**
158
- ```bash
159
- # Change the port mapping
160
- docker run -p 8502:8501 nz-legislation-analyzer
161
- # Or with docker-compose, modify the ports section
162
- ```
163
-
164
- 2. **Memory Issues**
165
- ```bash
166
- # Increase Docker memory allocation
167
- # Docker Desktop: Settings > Resources > Memory
168
- # Or add memory limits to docker-compose.yml
169
- ```
170
-
171
- 3. **Model Loading Errors**
172
- - Ensure sufficient RAM (8GB+ recommended)
173
- - Check that model files are accessible
174
- - Verify model path in configuration
175
-
176
- 4. **Permission Issues**
177
- ```bash
178
- # Fix directory permissions
179
- sudo chown -R $USER:$USER streamlit_app/
180
- ```
181
-
182
- 5. **Cache Issues**
183
- ```bash
184
- # Clear persistent cache
185
- sudo rm -rf streamlit_app/cache/*
186
- docker-compose restart
187
- ```
188
-
189
- ### Debug Mode
190
-
191
- Enable debug logging by modifying the environment:
192
-
193
- ```bash
194
- # Add to docker-compose.yml environment section
195
- - PYTHONPATH=/app
196
- - LOG_LEVEL=DEBUG
197
- ```
198
-
199
- ## πŸ”„ Updates and Maintenance
200
-
201
- ### Updating the Application
202
-
203
- ```bash
204
- # Pull latest changes
205
- git pull
206
-
207
- # Rebuild the image
208
- docker-compose build --no-cache
209
-
210
- # Restart services
211
- docker-compose up -d
212
- ```
213
-
214
- ### Backup Important Data
215
-
216
- ```bash
217
- # Backup cache and configuration
218
- tar -czf backup.tar.gz streamlit_app/cache/ streamlit_app/config/
219
-
220
- # Backup datasets
221
- tar -czf datasets_backup.tar.gz streamlit_app/datasets/
222
- ```
223
-
224
- ### Cleaning Up
225
-
226
- ```bash
227
- # Remove containers and volumes
228
- docker-compose down -v
229
-
230
- # Remove images
231
- docker rmi nz-legislation-analyzer
232
-
233
- # Clean up unused Docker resources
234
- docker system prune -a
235
- ```
236
-
237
- ## πŸ—οΈ Advanced Configuration
238
-
239
- ### Custom Model Files
240
-
241
- To use custom model files:
242
-
243
- 1. **Mount model directory:**
244
- ```yaml
245
- volumes:
246
- - ./models:/app/models:ro
247
- ```
248
-
249
- 2. **Update configuration** in the Streamlit app to point to `/app/models/your-model.gguf`
250
-
251
- ### GPU Support (Optional)
252
-
253
- For GPU acceleration with CUDA:
254
-
255
- ```dockerfile
256
- # Use CUDA-enabled base image
257
- FROM nvidia/cuda:11.8-devel-ubuntu22.04
258
-
259
- # Install Python and dependencies
260
- # ... (additional setup for CUDA)
261
- ```
262
-
263
- Note: GPU support requires additional configuration and CUDA-compatible hardware.
264
-
265
- ## πŸ” Security Considerations
266
-
267
- - The application runs in headless mode by default
268
- - All data is stored locally in mounted volumes
269
- - No external network access is required for basic functionality
270
- - Consider implementing authentication for production deployments
271
-
272
- ## πŸ“ˆ Performance Optimization
273
-
274
- ### Memory Management
275
-
276
- - Default cache size: 1024MB (configurable in app settings)
277
- - Adjust based on available system memory
278
- - Monitor memory usage through the app's Performance dashboard
279
-
280
- ### Disk I/O
281
-
282
- - Use SSD storage for better performance
283
- - Ensure adequate disk space for cache and datasets
284
- - Consider using tmpfs for temporary processing
285
-
286
- ### Network
287
-
288
- - The application binds to all interfaces (`0.0.0.0`)
289
- - Access via `localhost` or container IP
290
- - No external dependencies required
291
-
292
- ## πŸ†˜ Support
293
-
294
- For Docker-specific issues:
295
-
296
- 1. Check Docker logs: `docker-compose logs`
297
- 2. Verify Docker installation and version
298
- 3. Ensure adequate system resources
299
- 4. Review the main application logs in `streamlit_app/logs/`
300
-
301
- For application-specific issues, refer to the main documentation in `README_Streamlit_App.md`.
302
-
303
- ---
304
-
305
- **πŸŽ‰ Happy analyzing with your containerized NZ Legislation Loophole Analysis Streamlit App!**