Docs/Reference/dokwe.yml reference

dokwe.yml reference

13 min read
On this page

dokwe.yml describes how Dokwe builds and runs your project. It lives at the root of your repository and is validated against a JSON Schema, both by dokwe validate on your machine and by Dokwe at deploy time.

Where the file lives#

Dokwe looks for dokwe.yml at the repository root by default. The project's manifest path setting can point somewhere else. For monorepos, the path is resolved inside the project's root directory.

Native projects must have a valid manifest. A native deploy stops at the Resolving manifest phase if the file is missing, fails validation, or declares a mode that doesn't match the project. See Container or native.

Container projects take their build settings (install, build, and start commands, and a custom Dockerfile) from the project's settings in the dashboard. The container-mode keys below are accepted by the validator, but the deploy pipeline reads dokwe.yml only for native projects.

Files generated by dokwe init start with a schema comment for YAML editors that support yaml-language-server:

yaml
# yaml-language-server: $schema=https://dokwe.com/schemas/dokwe.schema.json

Generate a starter file#

dokwe init inspects the current folder, detects the framework, and writes a commented dokwe.yml.

bash
dokwe init

It detects laravel, nextjs, node, php, or generic. Override detection with --framework. In interactive mode it asks for the BYOS server name, whether to use a custom domain (and whether to redirect www), and the host path to deploy to. It also offers secret-looking keys from .env.example as env.required entries.

The generated file always uses mode: native. Without a custom domain, it leaves domain unset so the project uses its automatic domain. dokwe init refuses to overwrite an existing file unless you pass --force.

For CI, skip the prompts:

bash
dokwe init --non-interactive --host my-server --destination /var/www/my-app

In non-interactive mode, --host defaults to <folder-name>-prod and --destination defaults to /var/www/<folder-name>. See CLI reference for every flag.

Validate locally#

dokwe validate checks the file without contacting Dokwe. It runs the JSON Schema plus extra native-mode checks, prints errors and warnings with their path, and exits with status 1 on errors.

bash
dokwe validate
dokwe validate -f deploy/dokwe.yml

Dokwe runs the same rules at deploy time and writes any warnings to the deploy log.

Top-level keys#

Unknown keys are rejected everywhere in the file unless a section says otherwise.

KeyTypeRequiredModeDescription
modecontainer | nativeYesBothSelects the deploy path. Must match the project's deployment mode.
hoststringNative, see belowNative onlySlug of the BYOS server this project deploys to. Pattern ^[a-z][a-z0-9-]{0,62}$.
rootDirstringNoBothBuild context, relative to the repo root. Defaults to the repo root.
manifestPathstringNoBothPath to this file. Informational only: Dokwe uses the project's manifest path setting.
runtimeobjectNoNative onlyRuntime versions and packages the host must have. See runtime.
buildlist or objectNoBothBuild commands. See build.
installCommandstringNoContainerLegacy. Ignored when build is present.
buildCommandstringNoContainerLegacy.
startCommandstringNoContainerLegacy.
dockerfilestringNoContainerPath to a custom Dockerfile. Overrides auto-generation.
deployobjectNativeNative onlyWhere and how releases land on the host. See deploy.
releaselist of stringsNoNative onlyCommands run in releases/<sha>/ after extract, before the symlink swap. A non-zero exit aborts the deploy.
release_rollbacklist of stringsNoNative onlyCommands run during dokwe rollback, before the symlink is restored.
servicesmapNativeNative onlyHost services Dokwe manages. At least one. See services.
envobjectNoBothRequired keys and plain defaults. See env.
environmentsmapNoBothPer-environment overrides. See environments.

Mode rules#

  • mode: container rejects host, runtime, deploy, release, release_rollback, and services. Their presence is an error.
  • mode: native requires services and deploy. It also requires host, either at the root or in every entry under environments.

At deploy time, Dokwe sends a native release to the server set as the target environment's deployment target. host is checked by the validator and printed by dokwe validate. See Bring your own server.

runtime#

Native only. Before building, Dokwe checks the host for everything listed here. By default, it installs anything missing. Auto-install supports Ubuntu and Debian hosts.

KeyTypeDefaultDescription
phpstringPHP version, for example "8.3". Matched on major.minor.
nodestringNode.js version.
composerstringComposer version, for example "2.x".
pythonstringReserved.
rubystringReserved.
packageslist of strings, uniqueDistro package names, installed with apt.
extensionslist of strings, uniquePHP extensions, as listed by php -m. Installed from ondrej/php (Ubuntu) or sury (Debian).
autoInstallbooleantrueSet false to only verify. Dokwe then fails with a hint instead of installing.

Quote version numbers such as "8.3" so YAML keeps them as strings.

build#

Commands that produce your build. Two forms are accepted.

The shorthand is a list of commands:

yaml
build:
  - composer install --no-dev --optimize-autoloader
  - npm ci
  - npm run build

The long form is an object:

KeyTypeRequiredDefaultDescription
commandslist of stringsYesAt least one command.
wherecontrol-plane | hostNocontrol-planeWhere the build runs.
cachelist of stringsNoPaths to persist between builds. Only meant for where: host.

For native projects, Dokwe runs the commands in a clean sandbox on the control plane. The working tree after the last command becomes the release artifact.

The current native pipeline runs the build commands in the control-plane sandbox. It doesn't act on where or cache yet.

deploy#

Native only. Dokwe uses a Capistrano-style layout under destination: releases/, shared/, and a current symlink.

KeyTypeRequiredDefaultDescription
destinationstringYesAbsolute host path. Must start with /.
keepReleasesinteger, 1–50No5Older releases are pruned after a successful swap.
owner.userstringNowww-dataOwner of deployed files.
owner.groupstringNowww-dataGroup of deployed files.
sharedlist of strings, uniqueNoRepo-relative paths kept across releases and symlinked into each one. Absolute paths and .. are rejected.
lvSnapshotobjectNoOptional LVM snapshot for full-filesystem rollback. Omit to use release-symlink rollback only.
lvSnapshot.lvPathstringYes, in lvSnapshotAbsolute LV path. Must start with /dev/.
lvSnapshot.sizestringYes, in lvSnapshotSnapshot size, for example "5G". Pattern ^[0-9]+[GMK]$.

services#

Native only. A map of service name to service definition. Names must match ^[a-z][a-z0-9-]{0,29}$. Each service has a kind:

kindUse it for
nginx+php-fpmPHP apps such as Laravel, served by nginx and PHP-FPM
nginx-staticStatic sites, SPAs, or an nginx front for a Node or Bun process
systemdLong-running processes: app servers, queue workers, websockets
cronScheduled commands

Every kind accepts these keys:

KeyTypeDefaultDescription
disabledbooleanfalseSkip this service. Most useful in an environment override.
healthCheckobjectSee Health checks. Not accepted by cron.

Domains and routing#

For nginx+php-fpm and nginx-static, domain decides how traffic reaches the service:

  • domain unset. Dokwe routes the project's automatic domain (<slug>-app.dokwe.com) and every custom domain on the project's Domains tab to the service through its proxy, with HTTPS handled by Dokwe. See Custom domains and HTTPS.
  • domain set to a domain on the project's Domains tab. Dokwe routes that domain to this service through its proxy and handles HTTPS, so certbot doesn't run on the host. Use this to serve several sites from one project: give each service its own domain and add each domain on the Domains tab. Domains on the tab that no service names, such as the automatic domain, go to the web service.
  • domain set to any other hostname. Nginx on the host answers for that hostname directly. With the default sslMode: certbot, certbot on the host issues the certificate. You manage DNS.

nginx+php-fpm#

KeyTypeDefaultDescription
kindnginx+php-fpmRequired.
userstringOverride deploy.owner.user for this service.
groupstringOverride the group for this service.
domainhostnamePrimary server_name. Omit to use the automatic domain.
aliaseslist of hostnames, uniqueExtra server_names. Each redirects to domain with a 301. Ignored when domain is unset.
wildcardSubdomainbooleanfalseServe domain and *.domain from one vhost. Requires sslMode: external with both certificate paths.
rootstringpublicDocument root, relative to current/.
sslModecertbot | external | nonecertbotHow TLS is handled when domain is set.
sslCertificatestringHost path to the certificate. Required with sslMode: external.
sslCertificateKeystringHost path to the key. Required with sslMode: external.
clientMaxBodySizestring10MMaximum request body. Pattern ^[0-9]+[KMG]?$.
headersmap of stringsResponse headers added verbatim.
proxylistReverse-proxy blocks. See proxy.

Let's Encrypt HTTP validation can't issue wildcard certificates. For wildcardSubdomain, obtain a wildcard certificate with a DNS-01 tool such as acme.sh, then point sslCertificate and sslCertificateKey at it.

nginx-static#

Accepts the same keys as nginx+php-fpm, with these differences:

KeyTypeDefaultDescription
kindnginx-staticRequired.
tryFilesstring$uri $uri/ /index.htmlnginx try_files value.
sslCertificate, sslCertificateKeystringNot automatically required by sslMode: external. Required when wildcardSubdomain is true.

systemd#

KeyTypeRequiredDefaultDescription
kindsystemdYes
commandstringYesExecStart value. Runs through /usr/bin/env, not a shell.
userstringNowww-data
groupstringNowww-data
restartalways | on-failure | noNoalways
restartSecinteger, 0 or moreNo5
workingDirectorystringNo<destination>/current
environmentFilestringNo<destination>/shared/.env

The systemd unit is named <service-name>.service.

cron#

KeyTypeRequiredDefaultDescription
kindcronYes
schedulestringYesStandard five-field cron expression.
commandstringYesRuns as cd <current> && <command> >> /dev/null 2>&1.
runAsstringNowww-dataUser the command runs as.
user, groupstringNoAccepted by the schema.

The schema annotates runAs with a default of root, but Dokwe applies www-data when you leave it out. This stops scheduled commands from creating root-owned files in shared/.

proxy#

Each entry in proxy becomes an nginx location that forwards to an upstream.

KeyTypeRequiredDefaultDescription
pathstringYesnginx location value. Must start with /. A prefix match should end with /.
upstreamstringYeshost:port, for example 127.0.0.1:3000.
websocketbooleanNofalseForward WebSocket upgrades.
readTimeoutstringNo60sPattern ^[0-9]+(ms|s|m|h)$.
sendTimeoutstringNo60sSame pattern.

On nginx+php-fpm, a prefix path without a trailing / (such as /app) triggers a warning, because it would also match routes like /appraisals.

Health checks#

healthCheck takes one of three shapes, chosen by type.

KeyhttptcpcommandDefault
typeRequiredRequiredRequired
pathOptional/
expectStatusOptional[200, 301, 302]
portRequired, 1–65535
commandRequired. Non-zero exit means unhealthy.
timeoutSecOptionalOptionalOptional10
intervalSecOptionalOptionalOptional30
failureThresholdOptionalOptionalOptional3

Dokwe runs one health check per deploy: the nginx+php-fpm service's check if it has one, otherwise the first service that defines one. An http check on a site with its own domain asks https://<domain><path>, using the domain of the service that defines the check, or else of the nginx+php-fpm or nginx-static service that has one. If no service has a domain, an http check is skipped; use tcp or command instead.

env#

KeyTypeDefaultDescription
filestring.envNative. Path under shared/ that variables are written to. Ignored for container.
requiredlist of strings, uniqueKeys that must be set. A native deploy aborts if any is missing or empty. Pattern ^[A-Z][A-Z0-9_]*$.
defaultsmap of stringsPlain-text defaults. Key pattern ^[A-Z][A-Z0-9_]*$.

For native deploys, Dokwe builds the final set of variables in this order, with later sources winning:

  1. env.defaults in the manifest
  2. Project-level variables from the dashboard or dokwe env
  3. environments.<type>.env.defaults

Never put secrets in env.defaults. The file is committed to your repository. The validator warns when a key name contains key, secret, password, token, or credential and its value looks like a secret. Store secrets as environment variables instead.

environments#

Sparse, per-environment overrides. Each key is an environment type, such as development, staging, or production, and must match ^[a-z][a-z0-9-]{0,29}$. A null value means the environment exists and uses every default.

An override can contain these keys:

KeyType
hoststring, same pattern as root host
runtimeSame shape as runtime
buildSame shape as build
deploySame shape as deploy, so destination is required if you include it
releaselist of strings
release_rollbacklist of strings
servicesmap of service name to a partial service
envSame shape as env

Service overrides are partial: every field is optional, and the fields you list replace the root service's values. An override for a service that doesn't exist at the root triggers a warning and has no effect.

Dokwe picks the override whose key matches the type of the environment being deployed.

At deploy time, Dokwe currently applies the services and env parts of an override. env.required lists are combined with the root list. The other override keys are validated but not yet applied.

Container example#

A container project that uses a custom Dockerfile in a monorepo folder. Remember that container projects read their build settings from the dashboard.

yaml
# yaml-language-server: $schema=https://dokwe.com/schemas/dokwe.schema.json
mode: container
rootDir: apps/web
dockerfile: Dockerfile
env:
  required:
    - DATABASE_URL
  defaults:
    NODE_ENV: production
environments:
  staging:
    env:
      defaults:
        LOG_LEVEL: debug

Native example#

A Laravel app with a web server, a queue worker, and the scheduler, plus a staging override.

yaml
# yaml-language-server: $schema=https://dokwe.com/schemas/dokwe.schema.json
mode: native
host: my-server

runtime:
  php: "8.3"
  composer: "2.x"
  node: "20"
  extensions:
    - redis
    - intl

build:
  - composer install --no-dev --optimize-autoloader
  - npm ci
  - npm run build

deploy:
  destination: /var/www/my-app
  keepReleases: 5
  owner:
    user: www-data
    group: www-data
  shared:
    - storage
    - .env

release:
  - php artisan migrate --force
  - php artisan config:cache

services:
  web:
    kind: nginx+php-fpm
    root: public
    clientMaxBodySize: 64M
    healthCheck:
      type: http
      path: /
      expectStatus: [200, 301, 302]
  queue:
    kind: systemd
    command: php artisan queue:work --sleep=3 --tries=3
    restart: always
    restartSec: 5
  scheduler:
    kind: cron
    schedule: "* * * * *"
    command: php artisan schedule:run

env:
  file: .env
  required:
    - APP_KEY
    - DB_PASSWORD
  defaults:
    APP_ENV: production
    LOG_CHANNEL: stack

environments:
  staging:
    services:
      scheduler:
        disabled: true
    env:
      defaults:
        APP_ENV: staging

Because web has no domain, the app is served on its automatic domain and any custom domains you add in the dashboard.