App service
Services/Node.js (Nuxt)

Node.js (Nuxt) service

Node.js runtime service for building Nuxt apps from source, with a development workspace.

This service runs your code: its image is built from a Git repository, and each build is deployed to an app environment.

On Wodby

How Node.js (Nuxt) runs on Wodby

What Wodby sets up for an application that runs on this service. Check it before changing the start command, the port or connection settings in the code.

How the application is started

The image built by the service's Dockerfile starts the application with npm run start, from /usr/src/app. package.json must define a start script.

  • The application must listen on port 3000, on all interfaces. That is the port of the service's HTTP endpoint. The service sets NODE_PORT to that number; it does not set PORT. Read NODE_PORT, or default to 3000.
  • NODE_ENV is development in environments of type dev and production in every other type.

Build

The service's Dockerfile only copies the build context to /usr/src/app. It does not run npm install. Dependencies, and any compiled output, must be produced by the pipeline before the image is built, for example with wodby ci run -- npm ci, so that node_modules is part of what is copied. An image built without node_modules cannot load the application's dependencies.

A pipeline that passes a Dockerfile from the repository (wodby ci build node -f Dockerfile) uses that file instead.

The service declares no volume of its own: files written inside the container are lost when it is replaced.

Linked services

Links to other services reach the application as environment variables. Nothing in the image reads them: the application reads them itself. Do not hardcode hosts or credentials.

LinkVariables
Database (MariaDB, MySQL or PostgreSQL)DB_HOST, DB_PORT, DB_NAME (also DB_DATABASE), DB_USERNAME, DB_PASSWORD, DB_DRIVER (also DB_CONNECTION)
MailSMTP_HOST, SMTP_PORT
Redis or ValkeyREDIS_HOST, REDIS_PORT, REDIS_PASSWORD
OpenTelemetry CollectorOTEL_EXPORTER_OTLP_ENDPOINT, OTEL_EXPORTER_OTLP_PROTOCOL (http/protobuf), OTEL_EXPORTER_OTLP_HEADERS (the Collector's ingest token)

All links are optional. A variable is present only while its link exists and the linked service is enabled. The mail link carries no credentials. The OpenTelemetry variables are the standard SDK settings: an application or agent that uses an OpenTelemetry SDK exports to the Collector without further configuration; set OTEL_SERVICE_NAME to name the application in traces.

Environment

  • WODBY_HOSTS is a JSON array of the environment's hosts, not a comma-separated string. WODBY_PRIMARY_HOST and WODBY_PRIMARY_URL are the canonical ones for links generated outside a request.
  • WODBY_APP_SERVICE_NAME is this service's host name inside the environment. Other services reach the application at that name on port 3000.
  • WODBY_ENV_TYPE tells a development environment from a production-like one.

In a development workspace

  • The checkout is mounted at /usr/src/app and served as it is on disk.
  • Workspace setup installs dependencies with workspace-node prepare. The package manager is taken from packageManager in package.json, otherwise from the lockfile: pnpm-lock.yaml means pnpm, yarn.lock means Yarn, anything else npm. Installs follow the lockfile exactly (npm ci, --frozen-lockfile, --immutable), with development dependencies. Run it again after changing dependencies.
  • The application is started with the dev script of package.json when there is one, otherwise with start. WORKSPACE_NODE_COMMAND on the service replaces that command.
  • NODE_ENV is always development here, whatever the environment type. PORT is set, to NODE_PORT unless given, and HOST to 0.0.0.0.
  • A saved file is picked up without a restart or a deployment. A dev script is expected to watch the files itself. A start script runs the application once, so the checkout is watched for it: when a file changes, the application is stopped and started again in the same container, within a few seconds. node_modules, .git, .pnpm-store, .next, dist, build and coverage are not watched. A command set with WORKSPACE_NODE_COMMAND is run as it is, without that watcher; WORKSPACE_NODE_WATCH=0 turns the watcher off. For scripts with their own watcher, CHOKIDAR_USEPOLLING, CHOKIDAR_INTERVAL and WATCHPACK_POLLING are set, because a checkout on network storage needs polling. WORKSPACE_POLL_INTERVAL changes the interval, WORKSPACE_POLLING=0 turns this off.
  • node_modules/ and /.pnpm-store/ are kept out of Git status without touching .gitignore.
  • A change to variables or linked services still needs a deployment of the environment.

Check the result

  • curl -s -o /dev/null -w '%{http_code}' "localhost:$NODE_PORT" from the container shows whether the application answers on the expected port.
  • printenv | grep -E '^(DB|SMTP|REDIS)_' | cut -d= -f1 lists the link variables that are present.

Nuxt on Wodby

What this service adds to the Node.js service it is based on.

Build and start

The service's Dockerfile copies the build context to /usr/src/app, runs npm run build and starts the container with npm run start. package.json must define both scripts.

  • The supported production output is Nitro's default node-server preset: build with nuxt build and start with node .output/server/index.mjs. Do not set another Nitro preset, and do not use nuxt generate as the build script.
  • The Dockerfile does not install dependencies. The pipeline does it before the image is built (wodby ci run -- npm ci), and node_modules is copied with the code. Nuxt may stay in dependencies and type-checking tools in devDependencies. Keep the starter's postinstall: nuxt prepare script; it generates .nuxt and needs no runtime variables.
  • npm run build runs while the image is built. Runtime variables of the service, including the link variables and secrets, are not available to it. Do not read them in nuxt.config.ts: values computed there are fixed at build time. Read them at request time, in server routes, server middleware or server plugins.
  • The image build leaves out .git, .gitignore, .nuxt, .output and .data; nuxt build regenerates .nuxt.
  • The application must listen on port 3000. The Nitro server listens on PORT (or NITRO_PORT) and defaults to 3000; leave both unset.
  • The server stops on SIGTERM within its 30-second shutdown timeout, which matches the deployment's grace period.

Runtime configuration

Nuxt's runtimeConfig is the supported way to configure a built application. Declare each key in nuxt.config.ts with an empty or default value, and set it per environment with a variable named after it: NUXT_ plus the key path in upper snake case, for example NUXT_API_SECRET for runtimeConfig.apiSecret. Keys under runtimeConfig.public use NUXT_PUBLIC_ and are sent to the browser; never put secrets there. Only declared keys are overridden, values are parsed (true, numbers and JSON become non-strings), and .env files are not read by the production server.

The link variables of the Node.js service (DB_*, REDIS_*, SMTP_*) have no NUXT_ prefix, so they do not override runtime config. Read them with process.env inside server code.

Variables the service sets

VariableMeaning
NODE_ENVproduction in every environment type, including dev. The Node.js service's development value for dev is replaced, because the container runs a production build.
NUXT_APP_SECRETA generated 64-character hex secret, stable across deployments and different for each environment. It sets Nuxt's appSecret, which useSession and deriveSecret from nuxt/server, and modules built on them, require; without it they fail at request time. Changing it invalidates existing sessions and anything signed with derived secrets.
WORKSPACE_NODE_COMMANDThe start command of a development workspace, described below.

Linked services

The service adds no link variables. The database, mail and Redis or Valkey variables of the Node.js service apply unchanged. Server routes read them from process.env; they do not reach the browser.

In a development workspace

  • The application is started with node node_modules/nuxt/bin/nuxt.mjs dev --host "$HOST" --port "$PORT" --strictPort, not through the dev script of package.json. Options in that script do not apply. nuxt must be a dependency of the project.
  • The development server listens on 0.0.0.0:3000. Do not change the port in the project configuration.
  • The development server rejects requests for host names it does not know, with 403. Add the environment's hosts to vite.server.allowedHosts in nuxt.config.ts: WODBY_HOSTS holds them as a JSON array, and WODBY_APP_SERVICE_NAME is the internal name used by health checks. The boilerplate's nuxt.config.ts does this. Nuxt applies the list to its own endpoints, to Vite and to the hot-reload connection.
  • Hot module replacement uses the same port: the browser connects to /_nuxt/ on the page's own host, over wss behind HTTPS.
  • The workspace sets CHOKIDAR_USEPOLLING, and all of Nuxt's, Nitro's and Vite's file watchers poll, so saved files, new pages and new server routes are picked up without a restart. The one exception is the watcher that restarts the development server when nuxt.config.ts changes; the boilerplate adds watch: ['../nuxt.config.ts'] when polling is on, so Nuxt's polling watcher does it instead.
  • NODE_ENV is development here.
  • /.nuxt/, /.output/ and /.data/ are kept out of Git status, in addition to the Node.js service's paths.
  • The image build's npm run build does not run in a workspace.

Overview

Technical profile of Node.js (Nuxt)

The versions are the ones you can select for Node.js (Nuxt) in a stack or an app environment. The service itself is published in revisions, and a stack references a specific revision.

Service type

App service

Versions

26, 24, 22

Stacks

Stacks that include Node.js (Nuxt)

This public stack includes Node.js (Nuxt). You can create an app from a public stack as it is, or add the service to a stack of your own.

CI/CD

Build Node.js (Nuxt) from a Git repository

Start from a public boilerplate or connect your own repository. With Wodby CI, a push to the branch that an app environment follows starts a build of Node.js (Nuxt), and the pipeline deploys it.

Git providers

You connect a repository through an integration with its Git provider.

CI providers

Wodby CI is built in: the pipeline is the file .wodby/pipeline.yml in the repository. For a repository you connect, an external CI provider can run the same steps with Wodby CLI.

Container registries

Built images go to Wodby Registry by default, or to an external registry that you connect as an integration.

Environment variables from integrations

A variable integration stores the credentials of a third-party service once. Attach it to Node.js (Nuxt) and Wodby passes them to the container as environment variables at runtime, not during the image build.

Configuration

Node.js (Nuxt) service configuration

The Node.js (Nuxt) service declares the following. Where a value can be changed, a stack sets it and each app environment can override it.

Technical domains

Wodby gives each public HTTP port a technical domain with a TLS certificate and renews the certificate. A port that the service marks private gets no domain. You can add custom domains.

Service links

Each link is a connection from Node.js (Nuxt) to another service. A stack sets which service a link points to. The cards list the public services that can satisfy each link.