jj
Browse files- CELERY_SCHEDULING_SETUP.md +44 -0
- Dockerfile +9 -3
CELERY_SCHEDULING_SETUP.md
CHANGED
|
@@ -243,6 +243,50 @@ print(result)
|
|
| 243 |
|
| 244 |
## Production Deployment
|
| 245 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 246 |
### Using Docker
|
| 247 |
```bash
|
| 248 |
# Build and start all services
|
|
|
|
| 243 |
|
| 244 |
## Production Deployment
|
| 245 |
|
| 246 |
+
### Using Docker (Recommended for Hugging Face Spaces)
|
| 247 |
+
```bash
|
| 248 |
+
# Build the Docker image
|
| 249 |
+
docker build -t lin-app .
|
| 250 |
+
|
| 251 |
+
# Run the container
|
| 252 |
+
docker run -p 7860:7860 lin-app
|
| 253 |
+
|
| 254 |
+
# For Hugging Face Spaces deployment:
|
| 255 |
+
# 1. Update your Dockerfile (already done above)
|
| 256 |
+
# 2. Push to Hugging Face Spaces
|
| 257 |
+
# 3. The container will automatically start Redis + your app
|
| 258 |
+
```
|
| 259 |
+
|
| 260 |
+
### Using Docker Compose (Local Development)
|
| 261 |
+
```yaml
|
| 262 |
+
# docker-compose.yml
|
| 263 |
+
version: '3.8'
|
| 264 |
+
services:
|
| 265 |
+
redis:
|
| 266 |
+
image: redis:7-alpine
|
| 267 |
+
ports: ["6379:6379"]
|
| 268 |
+
volumes: [redis_data:/data]
|
| 269 |
+
command: redis-server --appendonly yes
|
| 270 |
+
|
| 271 |
+
app:
|
| 272 |
+
build: .
|
| 273 |
+
ports: ["7860:7860"]
|
| 274 |
+
depends_on: [redis]
|
| 275 |
+
environment:
|
| 276 |
+
- REDIS_URL=redis://redis:6379/0
|
| 277 |
+
volumes: [./:/app]
|
| 278 |
+
|
| 279 |
+
volumes: redis_data:
|
| 280 |
+
```
|
| 281 |
+
|
| 282 |
+
```bash
|
| 283 |
+
# Start all services
|
| 284 |
+
docker-compose up -d
|
| 285 |
+
|
| 286 |
+
# Check logs
|
| 287 |
+
docker-compose logs -f
|
| 288 |
+
```
|
| 289 |
+
|
| 290 |
### Using Docker
|
| 291 |
```bash
|
| 292 |
# Build and start all services
|
Dockerfile
CHANGED
|
@@ -2,9 +2,15 @@ FROM python:3.11
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# Install Node.js for frontend build
|
| 6 |
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
| 7 |
-
RUN apt-get update && apt-get install -y nodejs
|
| 8 |
|
| 9 |
# Copy and install Python dependencies
|
| 10 |
COPY requirements.txt .
|
|
@@ -27,5 +33,5 @@ RUN chmod +x start_app.py
|
|
| 27 |
# Expose port
|
| 28 |
EXPOSE 7860
|
| 29 |
|
| 30 |
-
#
|
| 31 |
-
CMD ["
|
|
|
|
| 2 |
|
| 3 |
WORKDIR /app
|
| 4 |
|
| 5 |
+
# Install system dependencies including Redis server
|
| 6 |
+
RUN apt-get update && apt-get install -y \
|
| 7 |
+
redis-server \
|
| 8 |
+
nodejs \
|
| 9 |
+
curl \
|
| 10 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 11 |
+
|
| 12 |
# Install Node.js for frontend build
|
| 13 |
RUN curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
|
|
|
|
| 14 |
|
| 15 |
# Copy and install Python dependencies
|
| 16 |
COPY requirements.txt .
|
|
|
|
| 33 |
# Expose port
|
| 34 |
EXPOSE 7860
|
| 35 |
|
| 36 |
+
# Start Redis server in background and then start the application
|
| 37 |
+
CMD ["sh", "-c", "redis-server --daemonize yes && python start_app.py"]
|