Docs/Deploy/Container or native

Container or native

5 min read
On this page

Every project deploys in one of two modes. Container mode builds a Docker image and runs it. Native mode builds a .tar.gz artifact and lays it out on your own server with systemd, nginx, and cron, the way you would by hand.

Which one to pick#

ContainerNative
What gets builtA Docker image per commitA .tar.gz artifact per commit
Where it runsDokwe Cloud or a BYOS serverA BYOS server only
ConfigurationAuto-detected, or your Dockerfiledokwe.yml in the repo (required)
Good forMost web apps and APIsStacks with several host processes, such as Laravel with queues and Reverb, or Rails with Sidekiq

You set the mode when you create the project, and you can change it later under Settings → Deployment mode.

Switching modes keeps existing deployments in history, but you can't roll back to them. They were built for the other format.

Container mode#

Container mode is the default and doesn't need a dokwe.yml. For each deployment, Dokwe picks a Dockerfile in this order:

  1. A custom Dockerfile saved in the project's Dockerfile tab.
  2. A Dockerfile in the repository, or in the root directory if you set one.
  3. A generated Dockerfile, based on the stack Dokwe detects.

Detection looks for these files at the build root:

FileDetected as
package.jsonNext.js, Nuxt, NestJS, a static SPA (has a build script but no start), or Node.js
requirements.txt or pyproject.tomlFastAPI, Django, Flask, or plain Python
go.modGo
GemfileRuby
PHP project filesLaravel, Composer-based PHP, or plain PHP
index.htmlStatic HTML

If nothing matches and there's no Dockerfile, the build fails with a message listing these files.

For monorepos, set Root Directory in the project settings. You can also override the install, build, and start commands. These overrides apply only when Dokwe generates the Dockerfile.

Native mode#

Native mode deploys to a BYOS server running the Dokwe agent. A deployment runs in phases you can follow in the build log:

  1. Clone the repository.
  2. Read and validate dokwe.yml (or the manifest path you set in settings). The manifest must say mode: native.
  3. Check the runtime on the host. By default the agent installs missing pieces (Ubuntu and Debian). The build log shows the install as it runs: every line apt prints (agent 0.5.2 or later), and a "still installing" line each minute. A first install of several packages can take 10 to 20 minutes. If another install is running on the server (automatic security updates, for example), the agent waits for it, and if an earlier install was cut off part-way it finishes that first (dpkg --configure -a). Agents older than 0.5.2 stop instead, and the deploy error says what to run.
  4. Run your build commands in a clean Docker sandbox on the Dokwe control plane. The resulting working tree becomes the artifact.
  5. Package the artifact.
  6. Send it to the agent on your server.
  7. Release it on the host.

If Dokwe itself restarts during a native deploy (for example while it's being updated), the deploy stops and is marked failed with "Dokwe restarted while this deploy was running". Deploy again: anything the agent already installed is found by the runtime check, so the next deploy skips it.

Ports and domains#

Dokwe's proxy reaches your nginx on a port Dokwe assigns to each environment (40000–49999), and sends it only the domains that belong to that environment: its own Dokwe address, plus the project's custom domains when it's the main environment (production once it's live). A staging deploy never takes production's domains.

On each deploy Dokwe checks the stored port. If it's outside that range (left over from container mode, say), one your dokwe.yml uses for an app, or another environment's, the environment gets a new port and the routes follow. After the deploy goes live, Dokwe rewrites the custom-domain routes and the log says where each domain lands.

Under deploy.destination, the agent keeps a Capistrano-style layout:

text
/var/www/my-app/
├── current -> releases/<sha>
├── releases/
│   └── <sha>/
└── shared/

Each deployment is unpacked into releases/<sha>/. Paths listed in deploy.shared are symlinked from shared/, so they survive across releases. Your release commands then run inside the new release directory, with your project's variables in their environment (the same ones the service gets from shared/.env), so a migration can read DATABASE_URL directly. release_rollback commands get them too. If any command exits non-zero, the deploy stops and the previous release stays active. When they succeed, current is switched to the new release and services are reloaded. Older releases beyond keepReleases (default 5, maximum 50) are pruned.

Environment variables are written to shared/.env by default (change it with env.file).

Service kinds#

Declare host processes under services. Each entry has a kind:

KindUse it forRequired keys
nginx+php-fpmPHP apps. Document root defaults to public.kind
nginx-staticStatic sites, SPAs, or an nginx front for a proxied appkind
systemdLong-running processes such as workers, queues, and Node serverskind, command
cronScheduled commands, using a 5-field cron expressionkind, schedule, command

If an nginx service has no domain, Dokwe routes your project's auto-domain (https://<slug>-app.dokwe.com) and any custom domains to it. If you set domain, nginx serves it directly and certbot handles TLS on the host.

Example dokwe.yml#

Run dokwe init to generate a starting manifest from your code, and dokwe validate to check it locally without a network call. Here is a Laravel example:

yaml
mode: native
host: web-1

runtime:
  php: "8.3"
  composer: "2.x"
  extensions:
    - mbstring
    - pdo_mysql
    - redis

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

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

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

release_rollback:
  - php artisan migrate:rollback --force

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

host is the slug of your BYOS server. Keys in env.required must be set in your project variables, or the deploy fails before anything is released. Never put secrets in env.defaults.

release_rollback runs when you roll back. Pair each release step that changes state, such as a migration, with a step that undoes it. See Rollbacks.

For every key, see the dokwe.yml reference.