- Vendored epub.js/pdf.js+worker/JSZip/DOMPurify in static/vendor/ - reader.html/reader.js servono i JS da /static (niente CDN, offline-ready) - CSP: rimosse allowlist CDN, aggiunto worker-src 'self' blob: - Test CSP aggiornati; tutti 16 verdi; verificato smoke test offline in container
3.4 KiB
Deploy di Bookish
Preparazione
# 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):
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:
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
2. Docker (consigliato in questo fork)
Usa i file Dockerfile e docker-compose.yml in root. Non montare un volume su /app: cancellerebbe il codice.
cp .env.example .env
# imposta BOOKISH_SECRET
docker compose up --build -d
Volume unico: bookish-data → /data (uploads, converted, bookish.db).
Gunicorn ascolta su 0.0.0.0:5000 con 1 worker. Healthcheck: GET /healthz.
3. Systemd Service
[Unit]
Description=Bookish Flask App
After=network.target
[Service]
Type=simple
User=bookish
WorkingDirectory=/opt/bookish
Environment=PATH=/opt/bookish/.venv/bin
Environment=BOOKISH_SECRET=your-secure-secret-key
ExecStart=/opt/bookish/.venv/bin/python app.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable bookish
sudo systemctl start bookish
Reverse Proxy (Caddy)
bookish.tuodominio.it {
reverse_proxy localhost:5000
}
Con Caddy ottieni automaticamente HTTPS tramite Let's Encrypt.
Dati persistenti
Bookish usa il filesystem per dati temporanei e un database SQLite per dati permanenti:
| 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:
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:
python app.py 8080
# Prova 8080, 8081, 8082...
Variabili d'ambiente
| Variabile | Default | Descrizione |
|---|---|---|
BOOKISH_SECRET |
obbligatorio se debug=false | Flask secret key |
BOOKISH_DATA_DIR |
directory progetto / /data in Docker |
Upload, convertiti, SQLite |
BOOKISH_DEBUG |
false |
Modalità debug (true/false) |
BOOKISH_CLEANUP_HOURS |
1 |
Ore prima di cancellare i file temporanei |
PORT |
5000 | Porta gunicorn / mapping compose |
Manutenzione
# 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