A repository with a package.json is built as a Node.js project. If no more specific framework is recognized (Next.js, Nuxt, NestJS...), Webgune looks for an Express, Fastify, Koa or Hono server, or a start script. The full list is on Supported frameworks.
What the build runs
| Step | Command |
|---|---|
| Install | npm ci --include=dev, or the frozen install of bun, pnpm or yarn depending on the lock file |
| Repository install scripts | preinstall, install, postinstall, prepare if they exist, after installation |
| Build | npm run build, if the script exists |
| Start | npm start, or the inferred command (see below) |
The runtime image starts from node:<version>-alpine, receives the built /app folder, and runs under the node user (uid 1000) with NODE_ENV=production. It contains neither a compiler nor Git.
Node.js version
Node.js 22 by default. For another version, add an .nvmrc file:
20
or a range in package.json:
{
"engines": { "node": ">=20 <23" }
}
.nvmrc, .node-version and volta.node come first, provided they respect engines.node. A range alone gives 22 if it accepts it, otherwise the most recent LTS version it accepts. >=18 therefore gives 22, not 18.
The lock file
| Committed file | Install |
|---|---|
package-lock.json | npm ci --include=dev |
bun.lock or bun.lockb | bun install --frozen-lockfile |
pnpm-lock.yaml | pnpm install --frozen-lockfile |
yarn.lock | yarn install --frozen-lockfile (Yarn 1) or yarn install --immutable (Yarn 2 and later) |
The install never modifies the file. If it is missing or out of date with package.json, the build fails with a message that says what to do: run the install locally and commit the file. Two builds of the same commit install the same versions.
Development dependencies (devDependencies) are installed: TypeScript, Vite or Prisma CLI are available during the build. They remain present in the runtime image.
Start command
In order:
- the
startscript inpackage.json(npm start); - the
mainfield, if it points to an existing file:node <main>; - the first existing file among the framework's usual entry points (
index.js,server.js,app.js, then the same undersrc/for Express); - otherwise the first one in that list, assuming the build produces it.
An explicit start script avoids any surprise:
{
"scripts": {
"build": "tsc",
"start": "node dist/index.js"
}
}
The command can also be replaced in the service settings (Custom start command).
Listening on PORT and 0.0.0.0
// Correct
app.listen(process.env.PORT || 3000, "0.0.0.0");
// The service starts but receives no requests
app.listen(3000, "localhost");
localhost refers to the service's own machine: requests coming from outside do not reach it. The service never becomes ready and the deployment fails.
Express
import express from "express";
const app = express();
app.use(express.json());
app.set("trust proxy", true);
app.get("/healthz", (_req, res) => res.send("ok"));
const port = Number(process.env.PORT) || 3000;
const server = app.listen(port, "0.0.0.0", () => console.log(`listening on ${port}`));
process.on("SIGTERM", () => server.close(() => process.exit(0)));
trust proxy makes Express read the visitor's address from the X-Forwarded-For header (req.ip) and the HTTPS protocol (req.secure).
Fastify
import Fastify from "fastify";
const app = Fastify({ logger: true, trustProxy: true });
app.get("/healthz", async () => "ok");
await app.listen({ port: Number(process.env.PORT) || 3000, host: "0.0.0.0" });
Fastify listens on 127.0.0.1 by default: the host: "0.0.0.0" option is essential.
Hono
import { serve } from "@hono/node-server";
import { Hono } from "hono";
const app = new Hono();
app.get("/healthz", (c) => c.text("ok"));
serve({ fetch: app.fetch, port: Number(process.env.PORT) || 3000, hostname: "0.0.0.0" });
TypeScript
Compile at build time and start on the produced JavaScript. tsx or ts-node in production lengthen startup and keep all the tooling in memory.
{
"scripts": {
"build": "tsc -p tsconfig.json",
"start": "node dist/server.js"
}
}
Prisma
A postinstall: prisma generate works: your repository's install scripts run after installation, with the build variables, so with DATABASE_URL. openssl, required by Prisma, is in the image. Migrations (prisma migrate deploy) cannot run at build time, which has no access to the database: see Database migrations.
Native modules
The compiler (python3, make, g++) is present during the build: bcrypt, sqlite3 or sharp compile if no binary exists for Alpine. The system libraries for canvas, puppeteer, fluent-ffmpeg, pg-native and a few others are added automatically (Supported frameworks). Playwright does not work on Alpine: use Puppeteer, or a Debian-based Dockerfile.
Private npm registry
Add an .npmrc file to the repository that reads the token from a variable:
//npm.pkg.github.com/:_authToken=${NPM_TOKEN}
@my-org:registry=https://npm.pkg.github.com
then create the NPM_TOKEN variable in the Variables panel. The NPM_TOKEN, NODE_AUTH_TOKEN, BUN_AUTH_TOKEN, YARN_NPM_AUTH_TOKEN and GITHUB_PACKAGES_TOKEN tokens are the only service variables available during dependency installation, along with the NPM_CONFIG_* settings.
Several processes
The image launches a single process. To use several cores, increase the number of instances (Availability and scaling) rather than using PM2's cluster mode. If the application crashes, Webgune restarts it: a process supervisor is not needed.
A background task (message queue, sending emails) is deployed separately, as a worker.
Common errors
| Symptom | Cause | What to do |
|---|---|---|
| Deployment fails, no error in the logs | Listening on localhost or on a fixed port | app.listen(process.env.PORT, "0.0.0.0") |
Cannot find module '/app/dist/index.js' | The build script does not produce this file | Align start with the build's actual output |
npm ci rejects the lock file | File out of date with package.json | npm install locally, then commit |
| Stop with code 137 | Service memory exceeded | See Limits and resources |
Updated on