Тип сервиса
Сервис Node.js (Strapi)
Среда выполнения Node.js для сборки headless CMS Strapi из исходного кода со связью с базой данных, хранилищем загрузок и рабочим пространством разработки.
Этот сервис запускает ваш код: его образ собирается из Git-репозитория, а каждая сборка развёртывается в окружение.
В StackMaster
Как Node.js (Strapi) работает в StackMaster
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_PORTto that number; it does not setPORT. ReadNODE_PORT, or default to 3000. NODE_ENVisdevelopmentin environments of typedevandproductionin 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.
| Link | Variables |
|---|---|
| Database (MariaDB, MySQL or PostgreSQL) | DB_HOST, DB_PORT, DB_NAME (also DB_DATABASE), DB_USERNAME, DB_PASSWORD, DB_DRIVER (also DB_CONNECTION) |
SMTP_HOST, SMTP_PORT | |
| Redis or Valkey | REDIS_HOST, REDIS_PORT, REDIS_PASSWORD |
| OpenTelemetry Collector | OTEL_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_HOSTSis a JSON array of the environment's hosts, not a comma-separated string.WODBY_PRIMARY_HOSTandWODBY_PRIMARY_URLare the canonical ones for links generated outside a request.WODBY_APP_SERVICE_NAMEis this service's host name inside the environment. Other services reach the application at that name on port 3000.WODBY_ENV_TYPEtells a development environment from a production-like one.
In a development workspace
- The checkout is mounted at
/usr/src/appand served as it is on disk. - Workspace setup installs dependencies with
workspace-node prepare. The package manager is taken frompackageManagerinpackage.json, otherwise from the lockfile:pnpm-lock.yamlmeans pnpm,yarn.lockmeans 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
devscript ofpackage.jsonwhen there is one, otherwise withstart.WORKSPACE_NODE_COMMANDon the service replaces that command. NODE_ENVis alwaysdevelopmenthere, whatever the environment type.PORTis set, toNODE_PORTunless given, andHOSTto0.0.0.0.- A saved file is picked up without a restart or a deployment. A
devscript is expected to watch the files itself. Astartscript 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,buildandcoverageare not watched. A command set withWORKSPACE_NODE_COMMANDis run as it is, without that watcher;WORKSPACE_NODE_WATCH=0turns the watcher off. For scripts with their own watcher,CHOKIDAR_USEPOLLING,CHOKIDAR_INTERVALandWATCHPACK_POLLINGare set, because a checkout on network storage needs polling.WORKSPACE_POLL_INTERVALchanges the interval,WORKSPACE_POLLING=0turns 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= -f1lists the link variables that are present.
Strapi 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 with NODE_ENV=production and starts the container with npm run start. package.json must define both scripts: strapi build and strapi start, as create-strapi generates them.
- The Dockerfile does not install dependencies. The pipeline does it before the image is built (
wodby ci run -- npm ci), andnode_modulesis copied with the code. TypeScript may stay indevDependencies. npm run buildcompiles the TypeScript project todistand builds the admin panel. Runtime variables of the service, including the secrets and the database URL, are not available to it, and it does not need them.- The image build leaves out
.git,.env,.tmp,.strapi,dist,buildandpublic/uploads. - The application must listen on port 3000. The service sets
PORTandHOST;config/server.tsmust read them, as the generated file does. - Strapi's own
GET /_healthanswers204without touching the database. Use it for health checks. - The project must use PostgreSQL through the
pgpackage. The stack's PostgreSQL service is required.
Variables the service sets
| Variable | Meaning |
|---|---|
NODE_ENV | production in every environment type, including dev. The Node.js service's development value for dev is replaced, because the container runs a production build. |
HOST, PORT | 0.0.0.0 and 3000. |
STRAPI_TELEMETRY_DISABLED | true. |
APP_KEYS | Two generated keys separated by a comma, for server.app.keys. Secret. |
API_TOKEN_SALT | Generated, for admin.apiToken.salt. Secret. |
ADMIN_JWT_SECRET | Generated, for admin.auth.secret. Secret. |
TRANSFER_TOKEN_SALT | Generated, for admin.transfer.token.salt. Secret. |
JWT_SECRET | Generated, for the Users & Permissions plugin. Secret. |
ENCRYPTION_KEY | Generated, for admin.secrets.encryptionKey. Strapi encrypts stored API tokens with it. Secret. |
Each secret is generated once per environment and stays the same across deployments. Changing APP_KEYS, ADMIN_JWT_SECRET or JWT_SECRET signs everybody out; changing ENCRYPTION_KEY makes stored API tokens unreadable in the admin panel; changing API_TOKEN_SALT or TRANSFER_TOKEN_SALT invalidates existing tokens of that kind.
Wodby also sets WODBY_PRIMARY_URL. The boilerplate's config/server.ts uses it as Strapi's url, so links in emails are absolute; PUBLIC_URL overrides it.
Linked services
| Link | Variables |
|---|---|
db | DATABASE_URL: postgresql://user:password@host:port/database, with the user name and password percent-encoded. Secret. The Node.js service's DB_* variables are set too. |
sendmail | SMTP_HOST and SMTP_PORT, from the Node.js service. |
redis | REDIS_HOST, REDIS_PORT and REDIS_PASSWORD, from the Node.js service. Strapi does not use Redis by itself. |
config/database.ts must use DATABASE_URL as connection.connection.connectionString when it is set and not combine it with the separate variables. The boilerplate's file does this. The in-cluster PostgreSQL service does not use TLS; for a managed server that requires it, set DATABASE_SSL=true and, if needed, DATABASE_SSL_REJECT_UNAUTHORIZED or DATABASE_SSL_CA.
The boilerplate's config/plugins.ts switches Strapi's email provider to @strapi/provider-email-nodemailer only when SMTP_HOST is set. SMTP_FROM sets the sender; it defaults to no-reply@ followed by WODBY_PRIMARY_HOST.
Behind the gateway
Wodby's gateway terminates TLS and forwards X-Forwarded-Proto and X-Forwarded-For. Strapi must trust them: set proxy: { koa: true } in config/server.ts. Without it, Strapi treats every request as plain HTTP: the admin panel's sign-in cookies are not marked Secure, cookies that require HTTPS in production (such as the session of the Users & Permissions plugin's third-party sign-in) cannot be set, and client addresses are the gateway's. The boilerplate also sets proxy.maxIpsCount to 1, so the client address is the one the gateway added to X-Forwarded-For.
With url set from WODBY_PRIMARY_URL, Strapi redirects / to the admin panel on the primary domain. The admin panel itself is built with relative paths and works on every domain of the environment.
Uploaded media
The local upload provider writes files to public/uploads, and Strapi serves them at /uploads/.... The image build replaces public/uploads with a link to /mnt/files, where the service mounts the uploads volume (10 GB by default). The image's entrypoint gives the volume to the node user when the container starts.
- Do not rely on files committed to
public/uploads: the image build leaves them out. - The volume is a single ReadWriteOnce disk. The service is not scalable: it runs one pod, and a new pod starts only after the old one has stopped, so a deployment has a short downtime.
- To keep media elsewhere, use an upload provider for object storage such as
@strapi/provider-upload-aws-s3; the volume then stays empty.
In a development workspace
- The application runs the
devpackage script,strapi develop. It compiles the TypeScript sources, serves the admin panel through Vite on the same port with hot reloading, and restarts the server when a file in the project changes (outsidepublic,src/admin,distandnode_modules). Strapi's Vite configuration allows every host name, so the environment's domains work without configuration. - File watching uses polling: the workspace exports
CHOKIDAR_USEPOLLING, which Strapi's file watcher follows. - The Content-Type Builder works only here. Content types created in it are written to
src/apiandsrc/components; commit them, together with the type definitions Strapi regenerates intypes/generated. NODE_ENVisdevelopmenthere, so the admin panel's cookies are not marked secure.- A TypeScript error stops the server until the file is fixed; the development server then restarts by itself.
- Media uploaded in a workspace is written to
public/uploadsin the checkout, not to theuploadsvolume. /.strapi/,/dist/,/build/,/.tmp/,/.strapi-updater.jsonand/public/uploads/are kept out of Git status, in addition to the Node.js service's paths.- The workspace uses the linked PostgreSQL database of its environment.
Обзор
Технический профиль Node.js (Strapi)
Версии
Основан на
Репозиторий исходного кода
Публичный Helm-чарт
Постоянные тома
Стеки
Стеки, в которые входит Node.js (Strapi)
CI/CD
Сборка Node.js (Strapi) из Git-репозитория
Strapi Boilerplate
Используйте его как есть или клонируйте в свой Git-аккаунт.
wodby/strapi-boilerplateCI-провайдеры
StackMaster CI встроен в платформу: пайплайн описывается в файле .wodby/pipeline.yml в репозитории. Для подключённого репозитория те же шаги может выполнять внешний CI-провайдер с помощью StackMaster CLI.
Реестры контейнеров
Собранные образы по умолчанию попадают в StackMaster Registry или во внешний реестр, подключённый как интеграция.
Переменные окружения из интеграций
Интеграция с переменными один раз сохраняет учётные данные стороннего сервиса. Подключите её к Node.js (Strapi), и StackMaster передаст их в контейнер как переменные окружения во время работы, а не при сборке образа.
Конфигурация
Конфигурация сервиса Node.js (Strapi)
Технические домены
Тома
Связи сервиса
Каждая связь — это подключение Node.js (Strapi) к другому сервису. На какой сервис указывает связь, задаёт стек. На карточках перечислены публичные сервисы, которые подходят для каждой связи.
db
Сервисы, которые подходят для этой связи
sendmail
Сервисы, которые подходят для этой связи
redis
Сервисы, которые подходят для этой связи
otel
Сервисы, которые подходят для этой связи