working containerized build
This commit is contained in:
@@ -102,9 +102,16 @@ Each stage is independent and can be re-run without re-running earlier stages (e
|
||||
├── main.py # Stage 1: Guardian scraper
|
||||
├── reader.py # Stage 2: LLM script generation
|
||||
├── tts_generator.py # Stage 3: TTS audio generation
|
||||
├── pipeline.py # Pipeline orchestrator (Docker)
|
||||
├── requirements.txt # Python dependencies
|
||||
├── README.md # This file
|
||||
├── CLAUDE.md # Developer guide
|
||||
├── Dockerfile # Docker container build
|
||||
├── docker-compose.yml # Docker Compose (optional Ollama sidecar)
|
||||
├── .env.example # Environment variable defaults
|
||||
├── server/
|
||||
│ ├── __init__.py
|
||||
│ └── app.py # Web server (MP3 index + file serving)
|
||||
├── scraper/
|
||||
│ ├── __init__.py
|
||||
│ ├── client.py # GuardianClient (HTTP + concurrency)
|
||||
@@ -150,3 +157,99 @@ Each stage is independent and can be re-run without re-running earlier stages (e
|
||||
| `data/output.json` | JSON object containing scraped articles with `headline`, `url`, `body`, and `scraped_at` fields. |
|
||||
| `data/scripts.json` | JSON array of objects with `headline` and `script` fields. |
|
||||
| `data/audio/*.mp3` | One MP3 file per article, named from the sanitized headline. |
|
||||
|
||||
## Docker Deployment
|
||||
|
||||
Run the pipeline as a self-contained Docker container with a built-in web UI for browsing and downloading newscast files.
|
||||
|
||||
### Quick Start
|
||||
|
||||
```bash
|
||||
# 1. Build the image
|
||||
docker build -t guardian-newscast .
|
||||
|
||||
# 2. Run (web UI on port 8080, data persisted in ./data/)
|
||||
docker run -d \
|
||||
--name guardian-newscast \
|
||||
-p 8080:8080 \
|
||||
-v ./data:/app/data \
|
||||
guardian-newscast
|
||||
|
||||
# 3. Open the web UI
|
||||
open http://localhost:8080
|
||||
```
|
||||
|
||||
### Volume Mapping
|
||||
|
||||
| Mount Point | Purpose |
|
||||
|-------------|---------|
|
||||
| `./data:/app/data` | **Required** — stores all pipeline outputs (output.json, scripts.json, audio/*.mp3). Host path is your choice. |
|
||||
|
||||
### Environment Variables
|
||||
|
||||
| Variable | Default | Purpose |
|
||||
|----------|---------|---------|
|
||||
| `OLLAMA_URL` | `http://host.docker.internal:11434/api/generate` | Ollama API endpoint |
|
||||
| `MODEL_NAME` | `gemma4:e2b` | Ollama model for script generation |
|
||||
| `PORT` | `8080` | Web server HTTP port |
|
||||
| `POLL_INTERVAL` | `21600` (6h) | Seconds between pipeline runs |
|
||||
| `DATA_DIR` | `/app/data` | Data directory inside container |
|
||||
| `TTS_VOICE` | `af_heart` | Kokoro TTS voice name |
|
||||
|
||||
Override via `.env` file (copy `.env.example`), `docker run -e`, or docker-compose.
|
||||
|
||||
### Web Server
|
||||
|
||||
The container serves a dark-themed page at `/` listing all MP3 files with:
|
||||
- Inline audio playback
|
||||
- Direct download links
|
||||
- Auto-refresh every 5 minutes
|
||||
|
||||
Access at `http://<host>:<PORT>` (default `http://localhost:8080`).
|
||||
|
||||
### Publishing
|
||||
|
||||
```bash
|
||||
docker build -t guardian-newscast .
|
||||
docker tag guardian-newscast truenas.local:30095/guardian-newscast:latest
|
||||
docker push truenas.local:30095/guardian-newscast:latest
|
||||
```
|
||||
|
||||
### Deploying on TrueNAS
|
||||
|
||||
```bash
|
||||
docker pull truenas.local:30095/guardian-newscast:latest
|
||||
docker run -d \
|
||||
--name guardian-newscast \
|
||||
--network host \
|
||||
-v /path/to/data:/app/data \
|
||||
-e OLLAMA_URL=http://127.0.0.1:11434/api/generate \
|
||||
-e PORT=30095 \
|
||||
--restart unless-stopped \
|
||||
truenas.local:30095/guardian-newscast:latest
|
||||
```
|
||||
|
||||
### Docker Compose
|
||||
|
||||
```bash
|
||||
# Minimal (pipeline only, Ollama on host)
|
||||
docker compose up -d
|
||||
|
||||
# Full (pipeline + Ollama sidecar)
|
||||
docker compose --profile full up -d
|
||||
```
|
||||
|
||||
### GPU Acceleration
|
||||
|
||||
The default Dockerfile uses `python:3.11-slim` (Debian), which has glibc — fully compatible with NVIDIA CUDA.
|
||||
|
||||
To run with GPU acceleration on TrueNAS:
|
||||
1. Install the [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html).
|
||||
2. Build with CUDA-enabled torch:
|
||||
```bash
|
||||
docker build --target gpu -t guardian-newscast:gpu .
|
||||
```
|
||||
(Add a `FROM python:3.11-slim AS gpu` stage with `pip install torch --index-url https://download.pytorch.org/whl/cu121`)
|
||||
3. Run with `--gpus all`.
|
||||
4. Minimum **4 GB VRAM** recommended for Ollama + Kokoro in the same container.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user