Add esbuild production bundle and multi-stage slim Docker image.

Bundle server (and mcp entry) into a single JS file with deps inlined, minify UI into one HTML, and ship only dist/ in the runtime image.
This commit is contained in:
2026-08-07 11:09:02 +02:00
parent 7b739607ff
commit 0dd548339c
7 changed files with 663 additions and 24 deletions

View File

@@ -1,3 +1,5 @@
const fs = require('fs');
const path = require('path');
const express = require('express');
const { WebshareClient } = require('./webshare');
const { caps, feed } = require('./torznab');
@@ -113,8 +115,13 @@ app.get('/resolve/:ident', async (req, res) => {
}
});
// ── UI static files ────────────────────────────────────────────────────────
app.use(express.static('ui'));
// ── UI static files (dev: ../ui from src/; production: dist/ui next to server.js)
const uiRoot =
process.env.UI_DIR ||
(fs.existsSync(path.join(__dirname, 'ui'))
? path.join(__dirname, 'ui')
: path.join(__dirname, '..', 'ui'));
app.use(express.static(uiRoot));
// ── UI API: JSON search ───────────────────────────────────────────────────
app.get('/api/search', async (req, res) => {