Skip to main content
Open console

Node, Go and Rust

Running an application that serves its own HTTP, with no bootstrap file.

6 min read

A Node, Go or Rust application serves its own HTTP, in place of PHP-FPM and nginx. There is no bootstrap file for any of them: your application reads the environment directly.

What is in front

The platform's proxy terminates TLS, routes the hostname and compresses responses.

When vallic.yaml names nginx, it is in front too and serves public/ without the application: see Nginx. There, rules of your own can send a path to a service beside the application. They can also cache what the application makes for a week.

What to read

Read these names from the environment:

PORT                what to listen on — bind this, not a port of your choosing
DATABASE_URL        one connection string, which is what most drivers take
REDIS_HOST          the cache, when the stack runs one — with REDIS_PORT
VALLIC_PRIVATE_DIR  a directory that outlives every release — where uploads go
VALLIC_LOG_DIR      where log files go, if you write any, to be collected

pg.Pool({connectionString}), sql.Open("postgres", url) and their equivalents take DATABASE_URL as it is. Its five parts are there too: see Variables.

A server listening on 127.0.0.1 is reachable by nothing: bind PORT on all interfaces, not localhost.

What is writable

Anything your application writes and expects to keep goes under VALLIC_PRIVATE_DIR (private/ at the root of the release). It is kept outside the release and linked back into every one. The release itself is mounted read-only while the application runs.

There is no public counterpart — nginx is not in front of you, so what gets served from where is your application's decision.

Declare a mount to keep a directory at a path of your own choosing the same way:

mounts:
  - uploads

Output to stdout and stderr is collected without any of this: see Logs.

More than one web server

Keep sessions in Valkey, at REDIS_HOST and REDIS_PORT: connect-redis and its equivalents take exactly those two.

Once an environment has two web servers, consecutive requests from one visitor can land on different machines. Anything kept in a process's memory is not there on the next request: express-session's default store, an in-memory cache.

What starts it, and where it listens

start and port both have defaults you can usually leave alone.

Node Go
Default command npm start bin/server, in the release
Default PORT 3000 8080

start is the command that serves. It only applies to a runtime that is its own web server.

port overrides the default. It changes both the PORT your application is given and the port the platform expects to reach. Set it there, not as a number in your code.

start: node dist/server.js
port: 4000

A binary that does not serve

start does not have to listen: it can process a queue, consume a stream or sit in a loop. Leave health out and the deploy succeeds on the process staying up, not on an HTTP answer.

The environment's hostname still points at that container, and with nothing listening it answers 502. That is harmless, but the environment looks broken to anyone who visits it.

A background process that belongs beside a site is better written as a worker. It is supervised the same way but has no port and no hostname attached:

workers:
  - name: queue
    command: bin/worker

Workers run your application's own image against the same release, so they need an application in the stack.

Node

version: 1
type: nodejs

runtime:
  node: '24'

services:
  - postgres: '18'

build:
  # npm's download cache is provided. This is the bundler's build cache,
  # which is what makes the second build of an unchanged app quick.
  cache:
    - .next/cache
  steps:
    - npm ci
    - npm run build
    - npm prune --omit=dev

deploy:
  steps:
    - 'npm run migrate'
  on_failure: rollback

health:
  path: /healthz

A database under services must be the one the environment was created with. A commit cannot add or change a database. Other services, such as Valkey, are started by the next deploy if the environment lacks them.

The version after each name is required, and the environment runs it from the next deploy. Read Service upgrade before you change one that keeps data.

The release keeps node_modules: npm prune at the end of the build drops what production does not need.

With no start, the image runs npm start, so a start script in package.json is enough. Add start when your entry point is something else:

start: node dist/server.js

On Bun

To run the same project on Bun, put bun: under runtime in place of node:. The type stays nodejs. The build runs in Bun's image, so its steps can be Bun's:

version: 1
type: nodejs

runtime:
  bun: '1.4'

build:
  cache:
    - node_modules
  steps:
    - bun install --frozen-lockfile
    - bun run build

The default start is bun run start. See Bun for what the image carries.

Go

version: 1
type: golang

runtime:
  go: '1.27'

build:
  steps:
    - go build -o bin/server ./cmd/server

start: bin/server

health:
  path: /healthz

start is optional for Go. The image runs bin/server in the release unless start names something else. A binary built anywhere else needs one: with nothing at bin/server, the container starts and immediately exits.

The release is that one binary, so there is nothing to prune. If your schema needs migrating, add a deploy step that runs your own migration tool.

The language version is keyed by the language (node, go, rust), whatever the type says. nodejs, node, next and express all mean Node; golang and go both mean Go.

Rust

version: 1
type: rust

runtime:
  rust: '1.99'

services:
  - postgres: '18'

build:
  steps:
    - cargo install --locked --path . --root .

deploy:
  steps:
    - 'bin/server migrate'

health:
  path: /healthz

cargo install --root . puts your binary in the release's bin/, and the image starts bin/server there. A package named server needs no start.

Cargo's registry and its build directory are kept between builds, outside the release. There is nothing to list under cache.

A rust-toolchain.toml is not obeyed: the version is the one under runtime. See Rust for what the image carries.

Cron

Nothing is scheduled for you: periodic work is yours to declare. It runs in the application's container against the live release:

cron:
  - name: digest
    schedule: '0 * * * *'
    command: node dist/jobs/digest.js

It runs on one machine only, however many web servers the environment has.

Restoring a backup clears no cache for you.

Health checks

Set health.path and a deploy waits for that path to answer before it counts as done. on_failure: rollback puts the previous release back if it never does.

The platform also watches production and tells you when it stops answering: see Notifications. Prefer an endpoint that checks the database to one that returns 200 because the process is alive.

Next