docs: update all docs with SQLite, API, content_hash, reader features

This commit is contained in:
truetype committed 2026-07-23 22:40:13 +02:00
1 parent c1421665c0
commit e62c50c616
5 files changed
+458 -199

No files matched your search

+126 -57
View File
@@ -1,81 +1,105 @@
# Deploy Bookish
# Deploy di Bookish
## Su Proxmox LXC (raccomandato)
### 1. Crea container LXC
```bash
pct create 120 local:vault/almalinux-9-default_20240918_amd64.tar.xz \
--storage local-lvm \
--memory 1024 \
--swap 512 \
--cores 2 \
--net0 name=eth0,bridge=vmbr0,ip=dhcp \
--ostype almalinux \
--unprivileged 1
pct start 120
pct enter 120
```
### 2. Installa dipendenze
```bash
# Python e strumenti di sviluppo
dnf install -y python3 python3-pip git python3-devel gcc \
pango-devel cairo-devel gdk-pixbuf2-devel
# Per WeasyPrint
dnf install -y libffi-devel redhat-rpm-config
```
### 3. Clona e setup
## Preparazione
```bash
# Clona il repository
git clone http://192.168.0.183:8085/truetype/bookish.git
cd bookish
# Ambiente virtuale
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# Verifica
python app.py
# → Avvia su 0.0.0.0:5000 (o porta libera successiva)
# → Crea automaticamente bookish.db
```
## Opzioni di Deploy
### 1. Proxmox LXC (consigliato)
Crea un container Linux privilegiato (Debian/Ubuntu):
```bash
pct create 100 local/vault/debian-12-standard_12.7-1_amd64.tar.zst \
--hostname bookish \
--storage local-zfs \
--rootfs 4 \
--cores 1 \
--memory 512 \
--net0 name=eth0,bridge=vmbr0,firewall=1,ip=dhcp
```
All'interno del container:
```bash
apt update && apt install -y python3 python3-venv python3-pip git
git clone http://192.168.0.183:8085/truetype/bookish.git /opt/bookish
cd /opt/bookish
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
```
### 4. Crea service systemd
### 2. Docker
```dockerfile
FROM python:3.12-slim
RUN apt-get update && apt-get install -y \
libpango-1.0-0 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 \
libffi-dev shared-mime-info
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
RUN mkdir -p uploads converted
EXPOSE 5000
CMD ["python", "app.py"]
```
Build e avvio:
```bash
docker build -t bookish .
docker run -d \
--name bookish \
-p 5000:5000 \
-v bookish_data:/app/uploads \
-v bookish_data:/app/converted \
-v bookish_db:/app \
--restart unless-stopped \
bookish
```
### 3. Systemd Service
```ini
# /etc/systemd/system/bookish.service
[Unit]
Description=Bookish Ebook Converter & Reader
Description=Bookish Flask App
After=network.target
[Service]
Type=simple
User=root
User=bookish
WorkingDirectory=/opt/bookish
ExecStart=/opt/bookish/.venv/bin/python /opt/bookish/app.py 5000
Environment=PATH=/opt/bookish/.venv/bin
Environment=BOOKISH_SECRET=your-secure-secret-key
ExecStart=/opt/bookish/.venv/bin/python app.py
Restart=always
RestartSec=5
Environment=BOOKISH_SECRET=your-secret-here
Environment=BOOKISH_DEBUG=false
RestartSec=10
[Install]
WantedBy=multi-user.target
```
```bash
systemctl daemon-reload
systemctl enable --now bookish
```
## Docker (alternativa)
```dockerfile
FROM python:3.11-slim
RUN apt-get update && apt-get install -y pandoc libpango-1.0-0 \
libcairo2 libpangocairo-1.0-0 libgdk-pixbuf2.0-0 && rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY . .
RUN pip install --no-cache-dir -r requirements.txt
EXPOSE 5000
CMD ["python", "app.py", "5000"]
sudo systemctl daemon-reload
sudo systemctl enable bookish
sudo systemctl start bookish
```
## Reverse Proxy (Caddy)
@@ -86,10 +110,55 @@ bookish.tuodominio.it {
}
```
Con Caddy l'HTTPS è automatico.
Con Caddy ottieni automaticamente HTTPS tramite Let's Encrypt.
## Pulizia e Manutenzione
## Dati persistenti
I file in `uploads/` e `converted/` vengono puliti automaticamente dopo 1 ora. Nessun DB da manutenere.
Bookish usa il filesystem per dati temporanei e un database SQLite per dati permanenti:
Per backup basta copiare la directory del progetto (escludendo `uploads/`, `converted/`, `.venv/`).
| Cosa | Dove | Persistente? |
|---|---|---|
| File caricati | `uploads/` | ❌ (pulizia 1h) |
| File convertiti | `converted/` | ❌ (pulizia 1h) |
| Segnalibri e posizioni | `bookish.db` | ✅ (SQLite) |
**Backup**: per salvare segnalibri e posizioni, copia `bookish.db`:
```bash
cp /opt/bookish/bookish.db /tuo/backup/
```
Il database si ricrea automaticamente se manca (perdendo però i dati precedenti).
## Configurazione Porta
Se `app.py` non trova la porta specificata, scorre in sequenza (`+1`) finché non trova una porta libera. Puoi specificare la porta di partenza come argomento:
```bash
python app.py 8080
# Prova 8080, 8081, 8082...
```
## Variabili d'ambiente
| Variabile | Default | Descrizione |
|---|---|---|
| `BOOKISH_SECRET` | `bookish-secret-key-change-in-production` | Flask secret key |
| `BOOKISH_PORT` | 5000 | Porta di partenza per la ricerca |
| `FLASK_DEBUG` | 0 | Modalità debug (1 per attivare) |
## Manutenzione
```bash
# Update app
git pull
source .venv/bin/activate
pip install -r requirements.txt --upgrade
systemctl restart bookish # se systemd
# Pulizia hard disk
rm -rf uploads/* converted/*
# Backup
cp bookish.db bookish.db.$(date +%Y%m%d).bak
```