Сервис приложения
Сервисы/Node.js (TanStack Start)

Сервис Node.js (TanStack Start)

Среда выполнения Node.js для приложений TanStack Start, собранных из исходного кода, с необязательными связями с базой данных, кешем и почтой.

Этот сервис запускает ваш код: его образ собирается из Git-репозитория, а каждая сборка развёртывается в окружение.

В StackMaster

Как Node.js (TanStack Start) работает в StackMaster

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.

TanStack Start 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 Node.js server: add the nitro() plugin from nitro/vite to vite.config.ts, build with vite build and start with node .output/server/index.mjs. This is TanStack Start's own Node.js hosting setup.
  • 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. Build tools such as Vite and Nitro may stay in devDependencies.
  • 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. Read them inside server functions, server routes or middleware at request time, not at module scope.
  • The image build keeps the repository's .gitignore and leaves out .git, .output, .nitro and .tanstack. Keep .output in .gitignore: Tailwind CSS skips the files it lists, and without that the server build generates a different stylesheet than the client build, so a stylesheet imported with ?url is linked under a name that does not exist. A plain import './app.css' in the root route avoids that in any case.
  • The application must listen on port 3000. The Nitro server listens on PORT and defaults to 3000; leave PORT unset.

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.
WORKSPACE_NODE_COMMANDworkspace-node vite-start, the start command of a development workspace.

Linked services

The service adds no link variables. The database, mail and Redis or Valkey variables of the Node.js service apply unchanged. Server functions and server routes read them from process.env. They do not reach the browser: only variables prefixed with VITE_ that exist at build time are compiled into client code.

In a development workspace

  • The application is started through Vite's JavaScript API with the project's own Vite configuration file, not through the dev script of package.json. Options in that script do not apply. Host, port, strictPort and file polling are set on top of the project's configuration, in memory; no file is written. vite 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.
  • Vite rejects requests for host names it does not know. Add the environment's hosts to server.allowedHosts: WODBY_HOSTS holds them as a JSON array. The boilerplate's vite.config.ts does this.
  • File watching uses polling, so saved files and new route files are picked up without a restart. The route tree in src/routeTree.gen.ts is regenerated by the development server; keep it in Git.
  • NODE_ENV is development here.
  • /.output/, /.nitro/ and /.tanstack/ 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.

Обзор

Технический профиль Node.js (TanStack Start)

Здесь перечислены версии, которые можно выбрать для Node.js (TanStack Start) в стеке или окружении. Сам сервис публикуется ревизиями, и стек ссылается на конкретную ревизию.

Тип сервиса

Сервис приложения

Версии

26, 24, 22

Стеки

Стеки, в которые входит Node.js (TanStack Start)

Node.js (TanStack Start) входит в этот публичный стек. Можно создать приложение из публичного стека как есть или добавить сервис в собственный стек.

CI/CD

Сборка Node.js (TanStack Start) из Git-репозитория

Начните с публичного шаблона проекта или подключите собственный репозиторий. В StackMaster CI push в ветку, за которой следит окружение, запускает сборку Node.js (TanStack Start), а пайплайн её развёртывает.

TanStack Start Boilerplate

Используйте его как есть или клонируйте в свой Git-аккаунт.

wodby/tanstack-start-boilerplate

Git-провайдеры

Репозиторий подключается через интеграцию с его Git-провайдером.

CI-провайдеры

StackMaster CI встроен в платформу: пайплайн описывается в файле .wodby/pipeline.yml в репозитории. Для подключённого репозитория те же шаги может выполнять внешний CI-провайдер с помощью StackMaster CLI.

Реестры контейнеров

Собранные образы по умолчанию попадают в StackMaster Registry или во внешний реестр, подключённый как интеграция.

Переменные окружения из интеграций

Интеграция с переменными один раз сохраняет учётные данные стороннего сервиса. Подключите её к Node.js (TanStack Start), и StackMaster передаст их в контейнер как переменные окружения во время работы, а не при сборке образа.

Конфигурация

Конфигурация сервиса Node.js (TanStack Start)

Сервис Node.js (TanStack Start) объявляет следующее. Если значение можно изменить, его задаёт стек, а каждое окружение может его переопределить.

Технические домены

StackMaster выдаёт каждому публичному HTTP-порту технический домен с TLS-сертификатом и продлевает сертификат. Порт, который сервис помечает как частный, домен не получает. Можно добавить собственные домены.

Связи сервиса

Каждая связь — это подключение Node.js (TanStack Start) к другому сервису. На какой сервис указывает связь, задаёт стек. На карточках перечислены публичные сервисы, которые подходят для каждой связи.

sendmail

Сервисы, которые подходят для этой связи

redis

Сервисы, которые подходят для этой связи