Backend Apps

Backend Apps

A Backend App is a long-running server that Ngris builds in an isolated sandbox and runs in-cluster, reached over global HTTPS through an endpoint. Ship a Go, Node, or Python service — or any stack that comes with a Dockerfile — and Ngris compiles it into a signed, scanned, digest-pinned image and runs it for you. No agent, no CLI, no server of your own to operate.

It runs a long-running backend. Your process starts once and stays up, listening on a port for requests. It is not a function invoked per-request — for a per-request, scale-to-zero handler, use a Serverless Function instead. If you want to host built files (a site or SPA) with no server, use a Static App instead.

Backend Apps come in two shapes, both carrying a backend Ngris runs:

  • Backend only (type managed) — a monolith server; every path is served by your backend.
  • Full-stack (type fullstack) — a static front end on the edge plus a path-routed backend (a Vercel-style split: /api/* hits the backend, everything else serves the static front end). See Full-stack apps.

Backend Apps require the application_hosting entitlement, plus managed-backend availability on your plan (the managed_backends entitlement — the on/off master gate). Without it, create returns 403 Managed backends are not available on your plan.

How a deploy works

Every deploy takes your source from code to a live URL through the same pipeline:

  • Upload a .zip of your source, or connect a Git repo so every push redeploys.
  • Ngris auto-detects your language — Go, Node, or Python — and builds it onto an Ngris-pinned minimal base (a Node app installs, builds and runs on Node.js 24); or, if your source has a Dockerfile, it builds that instead and your image decides the versions.
  • The build runs in a hardened, sandboxed job and produces a signed, vulnerability-scanned, digest-pinned container image.
  • Ngris runs that image isolated in its own sandbox and serves it through the endpoints you add to the app (a backend app gets none when it’s created). Because the image is immutable and pinned to its digest, rolling back to an earlier version needs no rebuild: Ngris rolls that image out again, and the earlier version takes over once its new instance is ready.

Every deploy builds a fresh image — a push, an upload or a Redeploy, even of the same commit — with the app's current build settings and variables.

A deploy moves through a series of statuses you can watch live: queued → building → image_ready → rolling_out → ready (or failed). An app with a release command runs it during rolling_out, before the new version takes traffic. Open Deploys → the deploy → Build log and the build log tails live while it runs, so you can see exactly what ran and why a build broke.

Build settings: install, build and start

Ngris detects how to install, build and start your backend. To use your own commands, open the app's Settings page and fill in Build settings, or send them with PUT /v1/applications/{uuid}. A box left empty is detected as before.

  • Start command (start_command) — how your server starts. It runs with a shell, so &&, quotes and variables like $PORT work. Your server must listen on 0.0.0.0 and the app's port, which it gets as $PORT. Examples: node dist/server.js, npm start, /app/server serve.
  • Install command (install_command, Node apps only) — runs instead of the install Ngris picks from your lockfile. Example: npm ci --legacy-peer-deps. If your build needs dev dependencies, install them too: npm ci --include=dev.
  • Build command (build_command) — runs after the install. For Node it replaces npm run build; for Python it runs once your dependencies are installed (they can be imported); for Go it replaces go build.

Saving doesn't rebuild. The next push, upload or Redeploy uses the new settings, and every deploy builds a fresh image.

curl -X PUT "https://api.ngris.com/v1/applications/{uuid}" \
  -H "X-API-KEY: <your_api_key>" \
  -H "Content-Type: application/json" \
  -d '{"build_command":"npm run build:server","start_command":"node dist/server.js"}'

Send "" to go back to detection. From the CLI: ngris apps settings --app <uuid> --start-command 'node dist/server.js'. You can also set them when you create the app (API, CLI or MCP), so its first build uses them.

npm start and other package scripts

A start command of exactly npm start, npm run <name>, yarn <name>, yarn run <name>, pnpm <name> or pnpm run <name> runs that script from your package.json, with your node_modules/.bin tools on the path. npm, yarn and pnpm don't run themselves, so prestart / poststart scripts don't run and the npm_* variables aren't set. If the script isn't in package.json, the build fails and says so. Any other npm, npx, yarn or pnpm command doesn't work as a start command: put it in a package.json script and start it with npm run <name>.

Python

  • Without a start command, Ngris finds your server (uvicorn or gunicorn) and binds it to the port for you. With your own start command, your server binds the port itself: uvicorn main:app --host 0.0.0.0 --port $PORT or gunicorn mysite.wsgi:application --bind 0.0.0.0:$PORT.
  • The server you start (uvicorn, gunicorn…) must be in your dependencies.
  • Python apps have no install command: set one and the build fails. Put extra steps in the build command, e.g. python manage.py collectstatic --noinput.

Go

  • Go apps have no install command either: put extra steps in the build command.
  • Your build command must write the server to /app/server, e.g. go build -o /app/server ./cmd/api. Only that file is shipped.
  • Start it with its arguments: /app/server serve.

Good to know

  • A command is one line of at most 1024 bytes: chain steps with &&. Line breaks, tabs and other invisible characters are refused.
  • Don't pipe your server's output (node server.js | tee app.log): an app started through a pipe doesn't stop cleanly when it is redeployed, restarted or scaled down. What it prints already reaches runtime logs.
  • Your own Dockerfile wins. It decides how the app is built and started, so with a Dockerfile in the app and any of these commands set, the deploy fails. Clear the commands in Settings, or remove the Dockerfile.
  • Only your project folder (/app) is shipped, and for Go only /app/server. Files a build writes anywhere else are lost.
  • Builds get the app's non-secret variables only, so an install from a private registry that needs a token fails. Your running server gets every variable, secrets included.
  • Commands are shown in the build log: don't type a token into one.
  • Versions are fixed: Node.js 24, Python 3.15 and Go 1.27. There is no version picker.
  • Settings aren't kept per deploy: every build uses the current ones, branch previews included. A rollback runs the earlier version as it was built, with the start command it had then.
  • A full-stack app's start command is its backend's; its backend install and build stay detected (or come from its Dockerfile). Its install command, build command and output directory are the front end's: see Full-stack apps.
  • Functions and WordPress sites have no build settings.

Release command: migrations before go-live

A release command runs once with each new deploy, before it goes live — the place for your database migrations, or any step the new version needs before it takes traffic. Set it in the app's Settings page under Release command, or send release_command with PUT /v1/applications/{uuid}. Leave it empty for none.

  • When it runs. Once the new version is built, Ngris starts one extra copy of it and runs the command there, before anything changes for your visitors. When it finishes with exit code 0, the new version rolls out as usual.
  • What it sees. The new version's files, all the app's environment variables and secrets, its databases and the same outbound network access as your server, with the app's CPU and memory. It runs with a shell, so &&, quotes and variables like $DATABASE_URL work. Examples: npm run migrate, python manage.py migrate --noinput, bin/rails db:migrate, /app/server migrate.
  • If it fails, nothing changes. A non-zero exit code, a command that can't start, or one still running at your plan's time limit fails the deploy, and the previous version keeps serving. The deploy shows what happened — Release command failed (exit 1) or Release command timed out after 10 min — with the last 50 lines of the command's output. Fix the cause and deploy again.
  • The time limit comes from your plan. The Release command card in Settings shows it. A command still running at the limit is stopped.
  • Once per deploy. A rollback to a version that was live before, a restart and a change of environment variables don't run it again. A deploy you build without making it live runs it when you promote it.

Make it safe to run again

A release command can stop half-way — a failure or the time limit — and a deploy that fails after its command finished (say, the new version never becomes healthy) runs it again on the next deploy. So write it to be run twice:

  • Use a migration tool that records what it has applied (Django, Rails, Alembic, Prisma, Flyway, golang-migrate, …) rather than raw SQL that fails the second time.
  • Keep each migration in one transaction where your database allows it. MariaDB and MySQL commit schema changes (ALTER TABLE, CREATE INDEX) one by one, so a step that adds a column checks first or tolerates Duplicate column.
  • The previous version keeps serving while the command runs, and after it if the deploy fails: change the schema so the old version still works (add columns and tables first, remove the old ones in a later deploy).

Good to know

  • Backend and full-stack apps (its backend) only. Static sites, WordPress sites and serverless functions have no release command.
  • The command is one line of at most 1024 bytes: chain steps with &&. Line breaks, tabs and other invisible characters are refused.
  • It runs with /bin/sh. The images Ngris builds have one; if you deploy your own Dockerfile, keep a shell in the image you ship.
  • One release command runs at a time per app: a new deploy that starts while the previous deploy's command still runs fails — deploy again once it has finished.
  • The values of your secret variables and database passwords are hidden in the output shown on the deploy. Don't print other credentials.
  • The file system is read-only apart from /tmp, as for your server.
curl -X PUT "https://api.ngris.com/v1/applications/{uuid}" \
  -H "X-API-KEY: <your_api_key>" \
  -H "Content-Type: application/json" \
  -d '{"release_command":"python manage.py migrate --noinput"}'

Your build context is the zip root

This is the single most common thing that trips up a first backend deploy, so read it before you zip.

The Docker build context is the root of your uploaded zip. Every Dockerfile COPY path is relative to that root. By default your Dockerfile must sit at the root of the zip, and the zip must be self-contained: no COPY ../…, no paths that assume a parent or monorepo directory, and no reliance on sibling directories that aren’t inside the zip. If a path points outside the context, the build fails.

Monorepos: build from a subdirectory

Monorepos are natively supported. Set the app's root_directory (its build subdirectory) — for example apps/web or packages/backend — and the build runs from that subdirectory: that folder's package.json / Dockerfile becomes the build root, and COPY paths are relative to it. Ship your whole repo (or subtree) and point root_directory at the app you want — no rewriting COPY paths and no vendoring.

Set it any of these ways:

  • CLI on create — ngris apps create <name> --type managed --root-dir apps/web.
  • CLI on an existing app — ngris apps settings --app <uuid> --root-dir packages/backend.
  • API — a root_directory field on POST /v1/applications and PUT /v1/applications/{uuid}.
  • Dashboard — the app's Settings pane.

An empty root_directory means the repo root — the default, unchanged behavior. The paths below still apply within the chosen subdirectory (a COPY ../… that escapes it still fails).

Alternative: flatten the prefix (no root_directory)

If you'd rather not set root_directory and instead zip just the app, watch the prefix. When your Dockerfile was written to build from the root of a monorepo (e.g. COPY myapp/web/… run from the repo root) but you upload only the app, the myapp/ prefix no longer exists inside the context and the build fails with something like:

failed to compute cache key: lstat /myapp/web/package.json: no such file or directory

Drop the prefix so paths are relative to the zip root (or just set root_directory and keep the Dockerfile as-is):

# BEFORE — assumes a monorepo root that isn't in the zip
COPY myapp/web/package.json ./
COPY myapp/web/ ./

# AFTER — relative to the zip root (the build context)
COPY web/package.json ./
COPY web/ ./

Alternative: vendor local modules into the zip

If you flatten instead of using root_directory, and your app depends on a local module via a replace directive — a monorepo sibling like a shared/ package that lives outside the app directory — that sibling is not in the context, so the build can’t resolve it. Copy the module into the zip and point the replace at the in-zip copy (or set root_directory to a subtree that already contains the sibling):

# zip layout: put the sibling INSIDE the app dir before zipping
#   myapp/
#     go.mod
#     main.go
#     shared/        <-- vendored copy of the local module

# BEFORE — replace points OUTSIDE the zip (a monorepo sibling)
# go.mod:  replace example.com/shared => ../shared

# AFTER — vendor it in, and point the replace at the in-zip copy
COPY . ./
RUN go mod edit -replace=example.com/shared=./shared \
 && go build -o /app/server ./...

The rule is simple: if the build needs it, it must be inside the zip. The build context has no access to your machine, your parent directories, or the rest of a monorepo — only what you uploaded.

What to put in the zip

Ship source, not build output — the build reinstalls and rebuilds your dependencies in the sandbox. A lean zip uploads less and avoids surprises. Exclude:

  • node_modules and any vendored dependency trees — the build installs them fresh (npm ci, go mod download, pip install).
  • Compiled or dist / build output — it’s regenerated inside the image.
  • .git — history isn’t needed to build.
  • Any .env with secrets — a committed .env can override the platform-injected config, and secrets don’t belong in an image. Set them as environment variables instead.

The cleanest way to enforce all of the above is a .dockerignore at the zip root:

node_modules
dist
build
.git
.env
*.log
Upload cap: 100 MB per deploy. A source zip that stays under the cap is a sign it’s lean — if you’re near the limit, you’re almost certainly shipping node_modules or build output you should exclude.

Environment variables & secrets

Set config, tokens, and connection strings under the app’s Environment settings (or the API). Ngris injects each variable into the running container’s process environment under its exact name — your app reads it with the normal env API of its language (os.Getenv("DATABASE_URL"), process.env.DATABASE_URL, os.environ["DATABASE_URL"]).

  • Mark sensitive values as Secret — they’re masked in the API and dashboard (write-only) and reach only your running app at start-up.
  • An empty value keeps an existing secret's value: editing a secret shows an empty box, and saving it untouched keeps the secret. Type a new value to replace it. A secret can't be set to an empty value; delete it instead.
  • Changes take effect on your next deploy or rollout — trigger one with a push, a re-upload, or by re-activating the current deploy.
  • Names must match [A-Za-z_][A-Za-z0-9_]*.
curl -X PUT "https://api.ngris.com/v1/applications/{uuid}/env" \
  -H "X-API-KEY: <your_api_key>" \
  -H "Content-Type: application/json" \
  -d '{"name":"LOG_LEVEL","value":"info","is_secret":false}'

Need a database? Create a managed MariaDB database under Storage → Databases and connect it from the app's Environment page (Connect database). ngris gives the app DB_HOST, DB_PORT, DB_NAME, DB_USER, DB_PASSWORD and a ready-to-use DATABASE_URL (or the same names behind a prefix you choose); they show in the variable list as locked rows. See Databases.

The port your app must listen on

The platform routes traffic to the port you configure for the app, so your server must listen on that port. Bind it on all interfaces — 0.0.0.0:<port>, not 127.0.0.1 — or requests won’t reach it.

Set the port in the app’s Serving settings (Settings page) (or PUT /v1/applications/{uuid}/runtime with port, valid 1–65535). If you don’t set one, the default expected port is 8080.

Ports below 1024 won’t bind. The container runs as a non-root user with all Linux capabilities dropped, so it cannot bind a privileged port. Listen on 8080, 3000, 8000, or any port ≥ 1024 — never 80 or 443. HTTPS is terminated for you at the endpoint.

Other runtime knobs live alongside the port: a health check path (health_check_path, default /), CPU & memory (cpu_millis, memory_mb), and replicas (min_replicas, max_replicas).

You choose each app’s size, up to what your plan allows: the plan sets a total of CPU and memory for all your backend apps together (an app counts once per replica), and a single app can take up to 4000 millicores and 8192 MiB. The Settings page shows the range that is still free for each app, and the API returns it as resource_limits on the app. A WordPress site needs at least 256 MiB. Memory is reserved in full; CPU is reserved at a quarter of what you set, and the app can use up to its full CPU whenever the node has it free.

WebSockets

Your app can take WebSocket connections on its port, like any other request. A browser’s new WebSocket("wss://<your app’s address>/ws") reaches your server as a WebSocket handshake with the usual X-Forwarded-For, X-Forwarded-Proto and X-Forwarded-Host headers, and from then on both sides talk directly.

  • Backend apps, the backend of a full-stack app, and WordPress take WebSockets. A serverless function answers one request at a time and doesn’t: use a backend app for them.
  • A WebSocket opens over HTTP/1.1, with a GET request that has no body, as browsers and WebSocket libraries do. Any other protocol switch is refused with 501.
  • Ping it. A WebSocket that stays silent for a while may be closed. Turn on your library’s pings; one every 30 seconds is plenty.
  • Reconnect when it closes. A WebSocket lasts at most 12 hours. It also closes when the copy of your app it is connected to stops (a deploy or a restart), and when the account is suspended or over its monthly limits.
  • Limits. Each open WebSocket counts against your plan’s Connections per tunnel (for the app), Connections per visitor IP, and Open WebSockets per account. Over one of them, the handshake gets 429 (try again in a second) or 503.
  • Usage. Its bytes count toward your monthly data transfer while it is open. The Traffic Inspector shows it as one WS request, with the bytes both ways.

Filesystem: read-only root, writable /tmp

The container runs with a read-only root filesystem. The only writable location is /tmp, a small scratch mount (~256 Mi).

  • Write any temp files — caches, uploads in flight, scratch output — only to /tmp. Point your framework’s temp dir there (TMPDIR=/tmp) if it defaults elsewhere.
  • Don’t try to write to the app directory, the working directory, or anywhere else at runtime — those writes fail. Bake everything the app needs at run time into the image at build time.
  • /tmp is ephemeral and per-instance — it’s wiped on restart and not shared between replicas. Persist real data in a managed database or an external store, never on the local filesystem.

Outbound network access

By default a running app has no internet access. It can resolve DNS and reach the managed databases it is connected to, and nothing else. Calls to an outside API, a webhook URL, or a package registry at runtime time out.

On a paid plan you can turn on outbound HTTP and HTTPS for one app by setting this environment variable:

NGRIS_EGRESS_HTTPS=on
  • The app can then open connections on TCP ports 80 and 443 to public IPv4 addresses.
  • Every other port stays blocked. For example, an external PostgreSQL on 5432 or SMTP on 587 can’t be reached this way.
  • Private and internal ranges stay blocked even on ports 80 and 443: 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 100.64.0.0/10, link-local 169.254.0.0/16 (including cloud metadata), loopback, multicast and reserved addresses. The app can’t reach other apps, Ngris’s internal network, or the cluster.
  • IPv6 destinations are not reachable.
  • The value must be exactly on (case doesn’t matter). true, 1 or any other value leaves outbound access off.
  • The variable has to apply to the deploy that’s running, so scope it to Production or Both. Saving it on a running app rolls the app out with the change; deleting it, or setting it to anything else, turns outbound access off again.
  • Outbound requests leave from Ngris infrastructure. There is no fixed source IP to allowlist.
Plan changes. On a plan without outbound access, setting the variable does nothing. If an account loses it (a downgrade, for example), Ngris removes outbound access from its running apps within about a minute, with no redeploy. After upgrading, save the variable again or redeploy to turn it on.

When your plan’s computing resources shrink

Your plan sets the computing resources of all your backend, full-stack, WordPress and function apps together — the total CPU and memory — and how many instances one app can run. When they shrink while your apps are running, after a downgrade or when extra resources the ngris team added to your account for a set time end, your apps adjust like this:

  • A grace period first. After a downgrade your apps keep running as they are until the grace period ends. The dashboard shows the date, and the email you get lists the apps that will pause then. Extra resources added for a set time end on their date, and pausing your subscription applies right away: neither has a grace period.
  • The oldest apps keep running. Ngris goes through your apps from the oldest to the newest and keeps each one running while it still fits. The newest apps that don’t fit are paused, so a smaller, newer app can keep running while a bigger one pauses. An app that alone needs more than your plan includes pauses even when it is the oldest.
  • Instances per app. An app set to autoscale to more instances than your plan allows keeps its setting and runs at most the plan’s number of instances. Its Settings page says so. After an upgrade it scales up to its own setting again.
  • Running apps keep their size. Ngris never makes a running app smaller on its own: CPU and memory stay what you set.
  • A paused app is kept. Visitors see “This site is paused.” It runs no instances, and its files, deploys, settings and data are kept. You can still view it, download its data, make it smaller or delete it; deploys and other changes wait until it runs again.

Resume a paused app

  • Upgrade. Paused apps resume, oldest first, as far as the new plan allows.
  • Make an app smaller. Lower the CPU, memory or maximum instances of any app — the paused one included — in its Settings page (a WordPress site: its WordPress page), or with PUT /v1/applications/{uuid}/runtime. Making an app smaller is always allowed, and so is any change that doesn’t make it bigger (port, health check, backend paths). Making it bigger is checked against what your plan has left.
  • Delete an app you no longer need.

Paused apps resume on their own within a few minutes, at their current settings, including changes you made while they were paused. When room frees up, the oldest paused app that fits resumes first, which can pause a newer app that only fitted while the older one was paused. If your plan doesn’t include computing resources for apps at all, only an upgrade resumes them. A paused app still counts: a new backend app can’t be created until your apps fit your plan.

Deploy a backend in 5 steps

Dashboard walkthrough

  1. Create the app. Open Applications → New and pick type Managed backend (or Full-stack if it also serves a static front end).
  2. Set env vars & secrets. Add your config under Environment, marking sensitive values as Secret. If you need a database, create one under Storage → Databases and connect it from the app's Environment page (Connect an app).
  3. Upload or connect. Choose Upload files and drop your source zip (self-contained, ≤ 100 MB), or Connect Git so every push redeploys.
  4. Watch the build. Open the deploy’s Build log — it tails live — and wait for the deploy to reach ready.
  5. Add an endpoint. Ngris doesn’t create one for a backend app: on the app’s Domains page choose Add endpoint to give it a URL (see Domains, endpoints & HTTPS). The app serves there once its deploy is ready. Add a custom domain any time — TLS is provisioned automatically.

API — create a backend app

curl -X POST "https://api.ngris.com/v1/applications" \
  -H "X-API-KEY: <your_api_key>" \
  -H "Content-Type: application/json" \
  -d '{"name":"my-api","type":"managed","source":"upload"}'

Use "type":"fullstack" for a static front end plus a path-routed backend, or "source":"git" with a repo_url to connect a repo instead of uploading.

API — upload the source & deploy

curl -X POST "https://api.ngris.com/v1/applications/{uuid}/deploys" \
  -H "X-API-KEY: <your_api_key>" \
  -F "file=@my-api-src.zip" \
  -F "version=v1.0.0"   # optional label

The build runs asynchronously. Poll GET /v1/applications/{uuid}/deploys until the newest deploy reaches ready, or stream the build log with GET /v1/applications/{uuid}/deploys/{deploy_uuid}/logs. Read live runtime status — instances, ready replicas, restarts — from GET /v1/applications/{uuid}/status. Give the app a URL with POST /v1/endpoints, sending "serving_mode":"agentless" and its application_uuid (see Create Endpoint).

Something wrong?

A build failing or the app not coming up? The Build log of a failed deploy shows exactly where the build stopped — a bad COPY path, a missing dependency, or a server that never bound its port. Walk the fixes in Deploy troubleshooting.
Was this helpful?