# πŸ“¦ Installation EverShelf runs on any server with PHP 8.2+ and SQLite (CI checks 8.2, the Docker image builds on 8.5). Docker is the recommended approach for the fastest setup. --- ## Prerequisites | Requirement | Minimum | Notes | |-------------|---------|-------| | PHP | 8.0+ | Extensions: `pdo_sqlite`, `curl`, `mbstring`, `json` | | Web server | Apache 2.4+ or Nginx | Apache `.htaccess` included | | SQLite | 3.x | Bundled with PHP on most distros | | HTTPS | Recommended | Required for camera access on mobile browsers | | RAM | 256 MB | 512 MB+ recommended if using AI features | --- ## Option A: Docker (recommended) > **Synology / Unraid bind mounts:** the web server inside the image runs as > UID **33** (`www-data`). If you map a host folder onto `/var/www/html/data`, > run `chown -R 33:33 ` once (or the splash fails with > β€œData directory / Disk write”). Details: [Synology](Synology), [Unraid](Unraid), > [FAQ](FAQ). The fastest way to get started. Pre-built multi-arch images (`amd64` / `arm64`) are published to **GHCR**: `ghcr.io/dadaloop82/evershelf`. ```bash # 1. Clone the repository (compose file + .env.example) git clone https://github.com/dadaloop82/EverShelf.git cd EverShelf # 2. Create your configuration cp .env.example .env nano .env # set AI_ENABLED, AI_PROVIDER (gemini|openai|llama), and provider credentials # 3. Pull the published image and start docker compose pull docker compose up -d # 4. Open in browser # β†’ http://localhost:8080 ``` To build locally instead of pulling: `docker compose build && docker compose up -d`. The Docker image: - Uses PHP-Apache on Debian Bookworm - Auto-creates the `data/` directory with correct permissions - Runs the maintenance cron **inside the container** (every 5 minutes: smart shopping, barcode sync, retentions and at most one database backup per day) - Exposes port `8080` by default (configurable in `docker-compose.yml`) - Persists data in a named Docker volume - Tags: `latest` (main), `vX.Y.Z` (releases), `sha-…` ### Changing the port Edit `docker-compose.yml`: ```yaml ports: - "8080:80" # change 8080 to your desired host port ``` ### Using HTTPS with Docker Add a reverse proxy (e.g. Traefik, Caddy, or Nginx Proxy Manager) in front of the container for automatic TLS. --- ## Option B: Manual (Apache) ```bash # 1. Clone into your web root git clone https://github.com/dadaloop82/EverShelf.git /var/www/html/dispensa cd /var/www/html/dispensa # 2. Create configuration cp .env.example .env nano .env # 3. Set permissions on the data directory chmod 755 data/ chown -R www-data:www-data data/ ``` Make sure `mod_rewrite` is enabled: ```bash sudo a2enmod rewrite sudo systemctl restart apache2 ``` Apache virtual host (or add to `.htaccess` which is already included): ```apache ServerName evershelf.local DocumentRoot /var/www/html/dispensa AllowOverride All Require all granted # Hide sensitive paths Require all denied SSLEngine on SSLCertificateFile /etc/ssl/certs/evershelf.crt SSLCertificateKeyFile /etc/ssl/private/evershelf.key ``` --- ## Option C: Manual (Nginx) ```nginx server { listen 443 ssl; server_name evershelf.local; root /var/www/html/dispensa; index index.html; ssl_certificate /etc/ssl/certs/evershelf.crt; ssl_certificate_key /etc/ssl/private/evershelf.key; location /api/ { try_files $uri $uri/ =404; location ~ \.php$ { fastcgi_pass unix:/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } } # Block sensitive files location ~ /\.env { deny all; } location ~ /data/ { deny all; } location ~ /backup\.sh { deny all; } location / { try_files $uri $uri/ /index.html; } } ``` --- ## HTTPS Setup Camera and microphone access (barcode scanning, voice) **require HTTPS** on all modern mobile browsers. ### Self-signed certificate (local network) ```bash openssl req -x509 -nodes -days 3650 -newkey rsa:2048 \ -keyout /etc/ssl/private/evershelf.key \ -out /etc/ssl/certs/evershelf.crt \ -subj "/CN=evershelf.local" \ -addext "subjectAltName=IP:192.168.1.100,DNS:evershelf.local" ``` Android will show a certificate warning β€” tap "Advanced β†’ Proceed" once. The kiosk app accepts self-signed certificates automatically. ### Let's Encrypt (public server) ```bash sudo apt install certbot python3-certbot-apache sudo certbot --apache -d evershelf.yourdomain.com ``` ### Caddy (automatic TLS) ``` evershelf.yourdomain.com { root * /var/www/html/dispensa php_fastcgi unix//run/php/php8.2-fpm.sock file_server respond /data/* 403 respond /.env 403 } ``` --- ## Cron Jobs Scheduled work keeps the predictions and the caches fresh. Every job is a plain CLI script and is safe to run by hand. **Docker: nothing to install.** The image ships `/etc/cron.d/evershelf`, which runs `api/cron_smart_shopping.php` every 5 minutes as `www-data` (output in `data/cron.log`). That single job also covers the barcode sync, the retention passes and the daily backup. Check it with: ```bash docker logs evershelf 2>&1 | grep -i cron tail -n 20 data/cron.log ``` **Bare metal:** schedule it yourself. ```bash # Edit crontab crontab -e # Smart shopping predictions + daily backup (every 5 minutes) */5 * * * * php /var/www/html/dispensa/api/cron_smart_shopping.php >> /var/www/html/dispensa/data/cron.log 2>&1 # Barcode catalog refresh (weekly; daily for small catalogs) 0 3 * * 0 php /var/www/html/dispensa/api/cron_barcode_catalog.php >> /var/www/html/dispensa/data/cron.log 2>&1 # Mealie recipe cache (weekly; only if the Mealie integration is configured) 0 4 * * 0 php /var/www/html/dispensa/api/cron_mealie_cache.php >> /var/www/html/dispensa/data/cron.log 2>&1 ``` > **A cron that stops running leaves no trace** β€” the data just stops moving and the UI > still looks fine. Turn on the **cron watchdog** (*Settings β†’ πŸ”” Notifiche β†’ ⏱️ Cron > watchdog*) and each job pings an external URL when it finishes, so what raises the > alarm is the *missing* ping. Healthchecks.io and Uptime Kuma push monitors both work; > see [Configuration β†’ Cron watchdog](Configuration#cron-watchdog-healthchecksio--uptime-kuma). > The backup panel is the second alarm: it shows the last backup and warns when it is > older than 8 days. --- ## Backup **Docker:** automatic. The in-container cron creates a backup of `data/evershelf.db` at most once every 23 hours (and the new one replaces the oldest beyond `BACKUP_RETENTION_DAYS`, default 3). `Settings β†’ πŸ’Ύ Backup` lists them, lets you run one now and restores one. `BACKUP_ENABLED=false` switches the automatic copy off. **Bare metal:** add the daily line to your crontab β€” or let the every-5-minutes `cron_smart_shopping.php` above do it, which is the same job the container runs. ```bash # Edit crontab crontab -e # Daily backup at 3 AM 0 3 * * * /var/www/html/dispensa/backup.sh ``` The `backup.sh` script snapshots `data/evershelf.db` into `data/backups/` with a timestamp, and keeps the newest `BACKUP_RETENTION_DAYS` of them (`.env`, default 3). Because the database runs in WAL mode it uses SQLite's online backup β€” `sqlite3 ... ".backup"`, or a PHP `PRAGMA wal_checkpoint(FULL)` when the `sqlite3` CLI is missing β€” instead of a plain file copy, which would silently drop the newest transactions. The in-app backup does the same through `VACUUM INTO`. The Docker image ships the `sqlite3` CLI, so the fast path is used there. > **The backups live inside the data volume.** `data/backups/` protects you from a > bad restore or a wrong deletion β€” not from losing the volume (a template change, a > `docker compose down -v`, a disk failure). Copy that folder off the volume, keep the > appdata folder in your Unraid backup, or enable Google Drive in the same panel. --- ## API Token & First-Run Pairing If you set `API_TOKEN` in `.env`, EverShelf protects every API action with it. The token is never handed to an anonymous request, so the first time you open the UI it asks for a one-time **pairing code**. On a device that is already paired, the live code is under **Settings β†’ System β†’ Security** (and Info). It is also printed in the server log: ```bash grep -i "pairing code" logs/evershelf_*.log | tail -1 # bare metal docker logs evershelf 2>&1 | grep -i "pairing code" | tail -1 # Docker ``` Enter it in the dialog and you are in. The code is valid for 30 minutes (refreshed on a paired device), and you pair once per browser/device. - Hard-refresh (`Ctrl+Shift+R`) if the dialog does not appear β€” an older service worker can still serve a stale `app.js`. - **Trusted LAN instead of pairing:** `API_BOOTSTRAP_OPEN=true` re-enables the old "any same-origin-looking request gets the token" behaviour. Only for a host that cannot be reached from the internet (see `SECURITY.md`). - **Other clients** (Home Assistant, MCP server, kiosk app) do not pair: give them the `API_TOKEN` value directly, as `?api_token=` or the `X-API-Token` header. β†’ [Configuration β†’ Protecting the API with a token](Configuration) --- ## Updating ```bash cd /var/www/html/dispensa git pull origin main # Database migrations run automatically on next page load ``` With Docker: ```bash docker compose pull docker compose up -d ``` --- ## Post-installation Once the app is running, open it in your browser and: 1. Go to **Settings** (βš™οΈ icon in the header) 2. Open **API Keys** β€” enable AI, choose exactly one of **Gemini**, **OpenAI (cloud)**, or **Llama** (local/remote), then use **Run test** to check latency 3. Optionally configure Bring!, TTS, and scale settings 4. Add your first product via the βž• button or barcode scan See [Configuration](Configuration) for the full list of settings.