# Deployment Deploy target: Linux server, Node 20+, nginx fronting `adapter-node` on 127.0.0.1:3000, systemd managing the process. Python 3.10+ with `inventree-part-import` installed alongside Node — we shell out to it for unknown parts. ## One-time setup ```bash sudo adduser --system --group --home /opt/inventree-stock-tool stock-tool sudo chown -R stock-tool:stock-tool /opt/inventree-stock-tool # As the service user: sudo -u stock-tool -H bash cd /opt/inventree-stock-tool # Python side python3 -m venv .venv source .venv/bin/activate pip install "inventree-part-import>=1.9.2" # 1.9.2+ required for InvenTree 1.x API # configure inventree-part-import's suppliers at # ~/.config/inventree-part-import/ (Digi-Key, Mouser, LCSC API keys) # Node side — pushed via git or rsync into /opt/inventree-stock-tool npm ci --omit=dev npm run build # Env cp .env.example .env $EDITOR .env ``` `.env` must contain at minimum `INVENTREE_HOST`, `INVENTREE_TOKEN`, and `INVENTREE_PART_IMPORT_BIN=/opt/inventree-stock-tool/.venv/bin/inventree-part-import`. ## systemd ```bash sudo cp deploy/inventree-stock-tool.service /etc/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable --now inventree-stock-tool sudo systemctl status inventree-stock-tool journalctl -u inventree-stock-tool -f ``` Adjust `User=`, `Group=`, `WorkingDirectory=` in the unit file to match your setup. The unit pins `INVENTREE_PART_IMPORT_BIN` via `.env` — the `PATH=` line in the unit is a fallback for when the binary is on a regular `bin` directory. ## nginx ```bash sudo cp deploy/nginx.conf.example /etc/nginx/sites-available/stock-tool sudo ln -s /etc/nginx/sites-available/stock-tool /etc/nginx/sites-enabled/ sudo nginx -t && sudo systemctl reload nginx ``` Then issue a cert: ```bash sudo certbot --nginx -d stock-tool.your-domain.example.com ``` ## Updating ```bash # on build server / laptop: rsync -az --delete --exclude=node_modules --exclude=build \ ./web/ stock-tool@host:/opt/inventree-stock-tool/ # on server: sudo -u stock-tool -H bash cd /opt/inventree-stock-tool npm ci --omit=dev npm run build exit sudo systemctl restart inventree-stock-tool ``` ## Tuning - `IMPORT_CONCURRENCY` (default 3) — number of concurrent `inventree-part-import` subprocesses. Bump up only if supplier APIs aren't rate-limiting you and InvenTree handles concurrent category/manufacturer writes cleanly. 3–4 is typically the sweet spot; higher values tend to produce 429s rather than speedups. - `IMPORT_TIMEOUT_SEC` (default 60) — per-attempt timeout. Raise if your supplier API is slow or the server cold-starts imports.