Skip to content

Commit 1162565

Browse files
committed
Update default staging domain to be a suffix of app domain, to make DNS entries and wildcard certs easier to setup
1 parent 429fc2a commit 1162565

16 files changed

Lines changed: 1152 additions & 37 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ This project uses [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- New production apps on a subdomain now create their staging app with the stage label after the app's label, for example `app.stage.example.com` for `app.example.com`, instead of `stage.app.example.com`. The staging apps of `*.example.com` are then all under `*.stage.example.com`, so one wildcard DNS record and one wildcard certificate cover them. This is the new `stage_at` mode `domain_suffix`, which is now the default for `system.stage_at`.
13+
- Existing apps are not affected: the staging location is stored when an app is created. Apps created without a domain (path apps on the default domain) and apps on a registrable domain such as `example.org` stage where they did before (`stage.<domain>`).
14+
- To keep the previous location for new apps, set `stage_at = "domain"` in the `[system]` config, or pass `--stage-at domain` / `stage_at="domain"` per app.
15+
- Wildcard certificate and explicit DNS setups need `stage.<domain>` and `*.stage.<domain>` entries for new subdomain apps.
16+
- For a domain outside `default_domain`, OpenRun assumes you control the parent of the app's hostname (registrable domains are detected with the Public Suffix List). If the hostname is the only name you control, such as `tools.customer.com` pointed at your server, set the staging location explicitly with `--stage-at`. See the [staging domain](https://openrun.dev/docs/configuration/networking/#staging-domain) docs.
17+
- `domain_suffix` is now a reserved `stage_at` value and can no longer name a custom staging domain.
18+
- Downgrade note: older versions do not know `domain_suffix` and treat it as a staging domain name. If you set `stage_at = "domain_suffix"` explicitly (in `openrun.toml`, dynamic config or an apply file), change it to `domain` or remove it before running an older version. The built-in default needs no action.
19+
1020
## [v0.20.14] - 2026-11-04
1121

1222
- Update to use HTTP health checks for NLB

‎cmd/openrun/app_cmds.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func appCreateCommand(commonFlags []cli.Flag, clientConfig *types.ClientConfig)
6060
flags = append(flags, newStringFlag("commit", "c", "The commit SHA to checkout if using git source. This takes precedence over branch", ""))
6161
flags = append(flags, newStringFlag("git-auth", "g", "The name of the git_auth entry in server config to use", ""))
6262
flags = append(flags, newStringFlag("spec", "", "The spec to use for the app", ""))
63-
flags = append(flags, newStringFlag("stage-at", "", `Where to create the staging app: "domain", "path", or a staging domain. Defaults to system stage_at ("domain" by default)`, ""))
63+
flags = append(flags, newStringFlag("stage-at", "", `Where to create the staging app: "domain_suffix" (app.stage.example.com), "domain" (stage.app.example.com), "path", or a staging domain. Defaults to system stage_at ("domain_suffix" by default)`, ""))
6464
flags = append(flags,
6565
&cli.StringSliceFlag{
6666
Name: "param",

‎docs/content/docs/Applications/Lifecycle.md‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,19 @@ mycode STG 1 NONE stage.example.com:/
8181

8282
The second app is the staging app for the first. `app list` shows only the main apps by default, the `--internal` option makes it show the linked apps.
8383

84-
By default, the staging app uses a staging subdomain (`system.default_stage_domain`, default `stage`) and the same path as the production app. So for an app at `https://example.com/`, the staging URL is `https://stage.example.com/`. For an app at `https://example.com/utils/app1`, the staging app URL is `https://stage.example.com/utils/app1`.
84+
By default, the staging app uses a staging subdomain (`system.default_stage_domain`, default `stage`) and the same path as the production app. So for an app at `https://example.com/`, the staging URL is `https://stage.example.com/`. For an app at `https://example.com/utils/app1`, the staging app URL is `https://stage.example.com/utils/app1`. For an app on its own subdomain, the stage label goes after the app's label: the staging URL for `https://app1.example.com/` is `https://app1.stage.example.com/`.
8585

86-
The staging location can be changed when creating the app. The server default is configured with `system.stage_at`.
86+
The staging location can be changed when creating the app. The server default is configured with `system.stage_at`. See [staging domain]({{< ref "docs/configuration/networking#staging-domain" >}}) for how the location is derived and the DNS and certificate setup for it.
8787

8888
| `app create` option | Staging location |
8989
| :--- | :--- |
90+
| `--stage-at domain_suffix` | The default. The stage label goes after the first label of the app's domain: `app1.stage.example.com` for `app1.example.com`, `stage.example.com` for `example.com` |
91+
| `--stage-at domain` | The stage label goes in front of the app's domain: `stage.app1.example.com` for `app1.example.com`. This was the default before `domain_suffix`, use it to keep that shape |
9092
| `--stage-at path` | The older path based location, where `_cl_stage` is suffixed to the production path |
9193
| `--stage-at <domain>` | The staging app is put on the specified domain |
9294

95+
The staging location is set when the app is created and does not change afterwards.
96+
9397
## Promoting Changes
9498

9599
When there are code changes, running `app reload` will update the staging environment.

‎docs/content/docs/Applications/Overview.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ The declarative app configuration uses Starlark syntax. An app is defined using
327327
| container_opts | true | dict | | The container options for the app |
328328
| container_args | true | dict | | The container build args options for the app |
329329
| container_vols | true | list string | | The container volumes for the app |
330-
| stage_at | true | string | system | Staging location for new prod apps: `domain`, `path`, or a staging domain |
330+
| stage_at | true | string | system | Staging location for new prod apps: `domain_suffix`, `domain`, `path`, or a staging domain. Applies when the app is created |
331331
| sidecars | true | list dict | | The [sidecar containers]({{< ref "docs/container/overview/#sidecar-containers" >}}) for the app, same JSON fields as `--sidecar` |
332332
| bindings | true | list string | | The paths of the [service bindings]({{< ref "docs/applications/servicebindings" >}}) to attach to the app |
333333
| jobs | true | list | [] | [Jobs and deploy hooks]({{< ref "jobs" >}}), declared with `job(...)`, dictionaries or JSON strings |

‎docs/content/docs/Configuration/Networking.md‎

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -180,25 +180,64 @@ fallback_unknown_domains = false # set true to route unknown hostnames to the de
180180

181181
## Staging Domain
182182

183-
New production apps get a linked staging app. By default, OpenRun creates the staging app on a staging subdomain and keeps the production path unchanged. For example, an app created at `example.com:/reports` gets a staging app at `stage.example.com:/reports`.
183+
New production apps get a linked staging app. By default, OpenRun creates the staging app on a staging subdomain and keeps the production path unchanged. An app created at `example.com:/reports` gets a staging app at `stage.example.com:/reports`, and an app on its own subdomain, `app.example.com:/`, gets a staging app at `app.stage.example.com:/`.
184184

185185
The default staging location is controlled by `system.stage_at`:
186186

187187
```toml {filename="openrun.toml"}
188188
[system]
189-
stage_at = "domain" # "domain", "path", or a staging domain
190-
default_stage_domain = "stage" # prefix used when stage_at is "domain"
189+
stage_at = "domain_suffix" # "domain_suffix", "domain", "path", or a staging domain
190+
default_stage_domain = "stage" # stage label used when stage_at is "domain_suffix" or "domain"
191191
```
192192

193-
| `stage_at` value | Staging location |
193+
| `stage_at` value | Staging app for `app.example.com:/` | Staging app for `example.com:/reports` |
194+
| :--- | :--- | :--- |
195+
| `domain_suffix` (default) | `app.stage.example.com:/` | `stage.example.com:/reports` |
196+
| `domain` | `stage.app.example.com:/` | `stage.example.com:/reports` |
197+
| `path` | `app.example.com:/_cl_stage` | `example.com:/reports_cl_stage` |
198+
| any domain, for example `staging.example.net` | `staging.example.net:/` | `staging.example.net:/reports` |
199+
200+
With `domain_suffix`, the stage label (`default_stage_domain`) goes after the first label of the app's domain: an app at `<name>.example.com` stages at `<name>.stage.example.com`. One wildcard DNS record and one wildcard certificate for `*.stage.example.com` then cover staging for all the apps that `*.example.com` covers. With `domain`, the label goes in front of the whole domain, which puts each staging app under its own app's hostname.
201+
202+
Some domains have no parent to put the label in. For these, `domain_suffix` prepends the label, the same as `domain`:
203+
204+
- the default domain itself (`default_domain`), which includes every app created without a domain
205+
- a registrable domain such as `example.org` or `example.co.uk`, or a hosted name such as `name.github.io`. These are identified using the [Public Suffix List](https://publicsuffix.org/), so that `example.org` does not stage at `example.stage.org`
206+
- a single label hostname or an IP address
207+
208+
Subdomains of `default_domain` get the label inserted whatever the list says, so `default_domain` should be a domain you control and not a public suffix. This is what makes `app.localhost` and internal names like `app.corp.internal` (with `default_domain = "corp.internal"`) stage at `app.stage.localhost` and `app.stage.corp.internal`.
209+
210+
{{< callout type="warning" >}}
211+
For a domain outside `default_domain`, OpenRun cannot know which DNS zone you control. It assumes you control the parent of the app's hostname. That is wrong when the hostname is the only name you were given: if a customer points `tools.customer.com` at your server, or you control just the delegated zone `team.corp.com` and create an app on that exact name, the staging app is derived as `tools.stage.customer.com` or `team.stage.corp.com`. The same applies to a provider domain which hands out subdomains and is not on the Public Suffix List. OpenRun does not verify the derived name: it may not resolve, or may resolve to a host you do not run. For such apps, set the staging location explicitly with `--stage-at stage.tools.customer.com` or `--stage-at domain`, or set `stage_at = "domain"` for the whole server.
212+
{{< /callout >}}
213+
214+
- If an app is created without an explicit domain, the domain modes use `default_domain` as the production domain when deriving the staging domain. A staging domain value ending in `.` is expanded relative to `default_domain`.
215+
- The server setting only controls the default for new production apps. The staging location is fixed when the app is created: changing `stage_at` later, or re-applying an app with a different `stage_at`, does not move an existing staging app. `openrun app list --internal` shows where each staging app is.
216+
- Override the default per app with `openrun app create --stage-at domain ...`, `--stage-at path ...` or `--stage-at staging.example.net ...`. In declarative apply files, use `stage_at="domain"`, `stage_at="path"` or `stage_at="staging.example.net"` in the `app(...)` definition for apps being created.
217+
- Domains and the stage label must be lower case ASCII, with internationalized domain names entered in their punycode (`xn--`) form. Requests are matched against app domains exactly as they were entered, and deriving the staging domain does not normalize the name. A name which is not a well formed hostname (an empty label, characters that cannot be mapped) gets the label prepended.
218+
- The stage label can have more than one label (`stage.eu`). A trailing `.` on it is ignored, and it cannot contain `:`.
219+
- `domain_suffix` is a reserved word in `stage_at`. It cannot be used as the name of a staging domain.
220+
221+
### DNS and certificates for staging
222+
223+
For production deployments, make sure DNS and certificates cover the staging hostnames. For local development, `*.localhost` names work at any depth with the default `localhost` domain.
224+
225+
When apps are subdomains of `example.com`, the full set of records is:
226+
227+
| Record | Serves |
194228
| :--- | :--- |
195-
| `domain` | `default_stage_domain` is prepended to the production domain, for example `stage.example.com:/reports` |
196-
| `path` | The production domain is kept and `_cl_stage` is suffixed to the path, for example `example.com:/reports_cl_stage` |
197-
| any domain | The specified domain is used with the production path, for example `staging.example.net:/reports` |
229+
| `example.com` | apps on the default domain |
230+
| `*.example.com` | production apps on subdomains |
231+
| `stage.example.com` | staging for apps on the default domain |
232+
| `*.stage.example.com` | staging for apps on subdomains |
233+
234+
A DNS wildcard `*.example.com` on its own also answers for `stage.example.com` and `app.stage.example.com`, but only while no other record exists at or below `stage.example.com`. Once any record is created there, including `*.stage.example.com` itself, both `stage.example.com` and `*.stage.example.com` need their own records. Creating all four records avoids the surprise.
235+
236+
A wildcard certificate matches exactly one label, so `*.example.com` does not cover `app.stage.example.com`. Add `*.stage.example.com` and `stage.example.com` to the certificate. Automatic certificates (Let's Encrypt and mkcert) are issued per hostname and need no extra setup.
237+
238+
In general, the staging name of a production hostname `app.<parent>` is `app.stage.<parent>`. An app at `x.team.example.com` stages at `x.stage.team.example.com`, which needs `*.stage.team.example.com` (or an exact record) in DNS and in the certificate.
198239

199-
- If an app is created without an explicit domain, `domain` mode uses `default_domain` as the production domain when deriving the staging domain. A staging domain value ending in `.` is expanded relative to `default_domain`.
200-
- For production deployments, make sure DNS and certificates cover the staging hostnames. A wildcard DNS entry such as `*.example.com` is the simplest setup when apps use subdomains. For local development, `*.localhost` names work with the default `localhost` domain.
201-
- The server setting only controls the default for new production apps. Override it per app with `openrun app create --stage-at path ...` or `openrun app create --stage-at staging.example.net ...`. In declarative apply files, use `stage_at="path"` or `stage_at="staging.example.net"` in the `app(...)` definition for apps being created.
240+
If the stage label is changed with `default_stage_domain`, replace `stage` in the names above with that value.
202241

203242
### List apps page
204243

‎docs/content/docs/QuickStart/managing-apps.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ The full list, including jobs, deploy hooks and MCP settings, is in [app configu
4646

4747
{{< theme-image light="/d2/quickstart_lifecycle_light.svg" dark="/d2/quickstart_lifecycle_dark.svg" alt="Apply or scheduled sync loads the declaration and app source into the staging app, which is then promoted to the production app" >}}
4848

49-
Every production app has a staging app at the same path on the `stage` subdomain, for example `stage.example.com/todo` for `example.com/todo`. Apply writes to staging. Promotion copies staging to production, so production only ever runs a version that was already running on staging.
49+
Every production app has a staging app at the same path on the `stage` subdomain, for example `stage.example.com/todo` for `example.com/todo` (and `todo.stage.example.com` for an app on its own subdomain `todo.example.com`). Apply writes to staging. Promotion copies staging to production, so production only ever runs a version that was already running on staging.
5050

5151
{{% steps %}}
5252

0 commit comments

Comments
 (0)