Node.js Express service that builds SEMOSS projects on demand. Accepts a zipped
client/ folder, runs pnpm install && pnpm build inside it, and returns the
compiled portals/ directory as a zip in the same HTTP response.
POST /build ──► extract zip ──► pnpm build ──► zip portals/ ──► return zip
- Synchronous — one HTTP request in, one zip out, no polling
- Stateless — each build gets an isolated temp directory, cleaned up after the response closes
- Capacity-limited —
MAX_CONCURRENT_BUILDS(default 3) guards each pod
| File | Purpose |
|---|---|
server.js |
Express server — the entire service |
Dockerfile |
node:20-alpine image with pnpm + zip/unzip |
k8s-manifests.yaml |
Namespace, Deployment, Service, HPA |
build-client.sh |
Shell script to call the service from the CLI |
| Var | Default | Notes |
|---|---|---|
PORT |
3000 |
Listening port |
MAX_CONCURRENT_BUILDS |
3 |
Requests above this get 503 |
BUILD_MEMORY_LIMIT_MB |
512 |
Applied via ulimit -v + NODE_OPTIONS |
BUILD_TIMEOUT_MS |
300000 |
5 minutes; build killed on exceed |
MAX_UPLOAD_MB |
100 |
Max size of uploaded zip |
WORK_DIR |
/tmp/builds |
Temp dir for extractions and builds |
UPLOADS_DIR |
/tmp/uploads |
Multer upload staging |
- Body:
multipart/form-datawith fieldsource(zip file) - Query params:
?buildCmd=— shell command to run (default:pnpm install && pnpm build)?outDir=— output folder name to zip and return (default:portals)
- Response:
application/zip(portals.zip) on success, JSON error on failure
Returns { status, activeBuilds, maxConcurrent }. Used as liveness probe.
Returns 200 when pod has capacity, 503 when saturated. Used as readiness probe.
The service handles both layouts automatically:
# Layout A — zip wraps the whole project root (preferred)
client/
package.json
vite.config.ts
src/
...
# Layout B — zip contains the client folder contents directly
package.json
vite.config.ts
src/
...
Layout B is auto-wrapped into client/ so Vite's outDir: "../../portals"
(relative to src/) always resolves to portals/ next to client/.
pnpm install
node server.jsTest with the helper script:
./build-client.sh /path/to/client-folder http://localhost:3000Output lands in ./dist-output/.
docker build -t build-service .
docker run -p 3000:3000 build-servicekubectl apply -f k8s-manifests.yamlThe deployment uses quay.io/semoss/smss-node-builder:latest.
The HPA scales between 2 and 10 pods based on CPU (70%) and memory (75%) utilisation. Each pod handles up to 3 concurrent builds.
- Change the default build command: edit the
buildCmddefault inserver.jsat thePOST /buildhandler (req.query.buildCmd || 'pnpm install && pnpm build') - Change the output folder: edit
req.query.outDir || 'portals'in the same handler - Tune resources: edit
k8s-manifests.yaml—resources.requests/limitsandConfigMapvalues - Add a new endpoint: add a route in
server.js; the server is a plain Express app