Staging and production
On this page
Every project comes with a pipeline of two environments, Staging and Production. New code lands in staging. When you're happy with it, you promote that exact build to production.
The default pipeline#
When you create a project, Dokwe sets up:
| Staging | Production | |
|---|---|---|
| Tracks a branch | Yes, the project branch | No |
| Gets new pushes | Yes | Only through promotion |
| Auto-domain | https://<slug>-staging-app.dokwe.com | https://<slug>-app.dokwe.com |
Pushes, the Deploy button, and dokwe deploy all build into the environment that tracks the project branch, which is staging. Production changes only when you promote.
What each environment has#
Each environment is a separate running copy of your app with its own:
- Environment variables. Project-level variables are shared defaults. Variables you set on an environment override them key by key, and keys you don't override still flow through. Manage them in the environment's Environment Variables tab. See Environment variables.
- Domains. The auto-domain plus any custom domains you add in the environment's Domains tab. See Domains.
- Deployment target. Dokwe Cloud or one of your servers, set under Settings → Deployment Target.
Promote staging to production#
Promotion doesn't rebuild. It takes the image staging already built and tested, and starts it in production.
Open the pipeline#
Open the project's pipeline view. Each environment shows its current live deployment.
Promote#
On the staging card, select Promote to Production. If production already runs the same build, the button reads No changes to promote.
Watch it go live#
If production is already running, Dokwe starts the promoted image beside it and checks that it answers (an HTTP request to
/every 2 seconds, two answers below 500 in a row, for up to 2 minutes). Only then does it take traffic and the old container stop, so visitors see no gap. If production isn't running yet, the promoted image just starts. The previous production deployment is markedrolled_back.
When you promote, Dokwe:
- Reuses the source deployment's image, tagged
<slug>:<commit-sha>. Nothing is rebuilt. - Starts the container with production's environment variables and domains, not staging's.
- Starts a fresh container, then copies any project files you uploaded into it again.
- Rolls the same image out to production's extra replicas, if you run more than one. See Replicas and routing.
Because the image is the same, code that reads configuration at build time keeps the values it was built with. Read anything that differs between environments at runtime.
Promote a specific commit#
To promote something other than staging's latest live build, use the commit picker on the staging card (the button titled "Choose specific commit to promote"). It opens Choose Commit to Promote, which lists recent staging deployments and marks any whose image is no longer available.
Rebuild and promote#
Images can be pruned from the server over time. If you try to promote a build whose image is gone, the promotion fails with Image pruned: use Rebuild & Promote, and Dokwe offers a Rebuild & Promote button. You also get this option in the commit picker when you choose a pruned commit.
Rebuild and promote:
- Rebuilds the same commit in staging first. This redeploys that commit to staging.
- Waits for that build to go live.
- Promotes the new image to production as usual.
If you rebuild an older commit, staging switches to that older commit too.
Auto-promote#
To skip the manual step, turn on Auto-promote staging → production in the pipeline view. Each time a staging deployment goes live, Dokwe promotes the same build to production. If the auto-promotion fails, the staging deploy stays live and you can still promote by hand.
Environments on your own servers#
Promotion doesn't copy images between servers. An image lives on the server that built it. If production runs on a BYOS server and staging was built on a different server, the promotion fails. Keep both environments on the same server when you rely on promotion. See Bring your own server.
Native environments are different: two of them can't share a server when they deploy to the same deploy.destination or use the same service names, because systemd units and nginx sites are named after services. Dokwe stops such a deploy and names the environment it would overwrite. Put staging on its own server, or delete it.
Add an environment#
On the project's Pipeline tab, select Add environment. Choose its type, name, branch and where it runs: Dokwe Cloud or one of your servers. A new staging goes before production, so promotion still runs left to right. A project has one production environment.
The new environment gets its own Dokwe address. Add its variables on its page before the first deploy. For a native app, pick a server no other environment of the project runs on (see above).
Delete an environment#
Open the environment, go to Settings, and use Delete environment in the Danger zone. Type the environment's name to confirm.
On a BYOS server, Dokwe's agent first removes the environment's app: its systemd units, nginx sites, cron jobs and release folder for a native app, or its containers. Anything another live app on the same server still uses is left in place, and the confirmation says what was kept. Then the environment's route, deploy history, variables and domains are deleted. Custom domains pinned to it go back to the project's main environment.
If the server's agent is offline, the delete stops so the app isn't left running unseen. You can then choose Delete anyway and clean the server up yourself.