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:
38
README.md
38
README.md
@@ -19,22 +19,34 @@ Webshare download links expire after roughly ten minutes, so the torrent never e
|
||||
## Layout
|
||||
|
||||
```
|
||||
src/
|
||||
index.js # Express app + optional Sonarr missing-episode search
|
||||
webshare.js # salt/login, search, file_link
|
||||
md5crypt.js # Unix $1$ MD5-crypt (Webshare password digest)
|
||||
torznab.js # caps + search feed XML
|
||||
torrent.js # bencode + fake torrent + info-hash
|
||||
qbt.js # qBittorrent Web API façade + download queue
|
||||
mcp-server.js # MCP tool registration (shared)
|
||||
mcp-http.js # Streamable HTTP transport mount for Express
|
||||
mcp.js # Optional MCP-only HTTP process
|
||||
ui/ # Web UI: search & queue management
|
||||
src/ # source (CommonJS modules)
|
||||
ui/ # Web UI source (index.html, styles.css, scripts.js)
|
||||
scripts/build.mjs # esbuild: single server.js + minified single-file UI
|
||||
dist/ # build output (gitignored; produced by npm run build / Docker)
|
||||
server.js # one file: app + all npm dependencies
|
||||
mcp.js # optional MCP-only entry
|
||||
ui/index.html # CSS+JS inlined
|
||||
__tests__/
|
||||
compose.yaml
|
||||
Dockerfile
|
||||
Dockerfile # multi-stage: build with esbuild, runtime = Node + dist only
|
||||
```
|
||||
|
||||
## Build (smaller image / single JS)
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run build # → dist/server.js (~2 MB, all deps bundled) + dist/ui/index.html
|
||||
npm start # node dist/server.js
|
||||
npm run start:dev # unbundled src/ for local hacking
|
||||
```
|
||||
|
||||
**esbuild** bundles the server (and optional `mcp` entry) into a **single `.js` file** with
|
||||
dependencies inlined — no `node_modules` needed at runtime. The Web UI is minified into
|
||||
**one** `dist/ui/index.html` (CSS and JS inlined).
|
||||
|
||||
Docker uses a multi-stage build: final image copies only `dist/`, not source or
|
||||
`node_modules`, which keeps the image much smaller than `npm ci --omit=dev`.
|
||||
|
||||
## Configuration
|
||||
|
||||
Environment variables (required unless noted):
|
||||
@@ -71,9 +83,11 @@ See `compose.yaml`. Override ports, `BASE_URL`, Sonarr settings, and volume moun
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm run build
|
||||
export WEBSHARE_USERNAME=...
|
||||
export WEBSHARE_PASSWORD=...
|
||||
npm start
|
||||
# or: npm run start:dev # no build step, uses src/
|
||||
```
|
||||
|
||||
## Sonarr / Radarr
|
||||
|
||||
Reference in New Issue
Block a user