Skip to content

feat(domains): add toggle to enable/disable domains - #4697

Merged
narcisonunez merged 13 commits into
Dokploy:canaryfrom
gentslava:feat/domain-enable-disable
Aug 11, 2026
Merged

narcisonunez merged 13 commits into
Dokploy:canaryfrom
gentslava:feat/domain-enable-disable

Conversation

@gentslava

@gentslava gentslava commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What is this PR about?

Adds an enabled flag to domains so a domain can be switched off without deleting it, preserving its configuration. A switch is added to the Domains tab (grid card host row + a Status column in the table view).

  • Schema: new enabled column (default true) + migration; included in apiUpdateDomain.
  • Applications: guard in manageDomain so a disabled domain never exposes a traefik router from any caller (create/update/forward-auth/toggle); applies instantly via the file provider.
  • Compose: addDomainToCompose skips disabled domains when generating docker labels, so the change applies on the next deployment.
  • API: new domain.toggleEnable procedure (permission-checked + audited); returns requiresRedeploy for compose.
  • UI: switch on the domain card and a Status column in the table; disabled cards are dimmed. Reuses the existing compose "redeploy required" hint, now shown consistently across add/edit/delete/toggle.

Checklist

Before submitting this PR, please make sure that:

  • You created a dedicated branch based on the canary branch.
  • You have read the suggestions in the CONTRIBUTING.md file https://github.com/Dokploy/dokploy/blob/canary/CONTRIBUTING.md#pull-request
  • You have tested this PR in your local instance. Verified for an application (the traefik router file appears/disappears on toggle) and a compose service (DB flag + label filtering + redeploy hint). Added unit tests for the compose label filtering; the full traefik + compose suite passes (195 tests).

Issues related (if applicable)

closes #4696

Screenshots (if applicable)

Снимок экрана — 2026-06-25 в 00 44 10

Greptile Summary

The PR adds an enabled state for application and Compose domains, with persistence, permission-checked toggling, UI controls, and routing reconciliation.

  • Disabled application domains are removed immediately from Traefik’s file-provider configuration.
  • Compose deployment generation removes old domain labels from every service before regenerating labels for enabled domains.
  • Cleanup and regeneration support both list-style and mapping-style labels for Docker Compose and Swarm Stack.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported stale-label, prior-service, and mapping-label issues are addressed by current cleanup and regeneration behavior.

Reviews (7): Last reviewed commit: "test(compose): enable domain in security..." | Re-trigger Greptile

Context used:

@gentslava
gentslava requested a review from Siumauricio as a code owner June 24, 2026 18:04
@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. enhancement New feature or request labels Jun 24, 2026
@cheetahbyte

Copy link
Copy Markdown
Contributor

Hi, like the change!
Quick UI thought: since the toggle already shows the state, the "Enabled"/"Disabled" text feels a bit redundant

gentslava and others added 4 commits July 13, 2026 18:10
Compose domains are rendered as docker labels and only take effect on the
next deployment. Extract the "redeploy required" notice into a reusable
component/strings and surface it consistently: as a banner in the domains
list, in the add/edit dialog (replacing the inline copy), and in the toast
shown after create/update/delete. Unify grid deletion onto the shared
handler so the hint applies in both grid and table views.

Groundwork for the upcoming domain enable/disable toggle.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add an `enabled` flag (default true) so a domain can be switched off
without deleting it, preserving its configuration.

- schema: new `enabled` column + migration; added to apiUpdateDomain
- traefik (applications): guard manageDomain so a disabled domain never
  exposes a router from any caller (create/update/forward-auth/toggle);
  applies instantly through the file provider
- compose: skip disabled domains when generating docker labels, so the
  change applies on the next deployment
- tRPC: new domain.toggleEnable procedure (permission-checked + audited),
  returns requiresRedeploy for compose domains
- UI: switch on the domain card (host row, variant E) and a Status column
  in the table view; disabled cards are dimmed; reuses the compose
  redeploy hint for the toast

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add unit tests for addDomainToCompose verifying that a disabled domain
produces no traefik labels, an enabled domain does, and only the enabled
one emits labels when both are attached to the same service. Mocks node:fs
so loadDockerCompose runs against an in-memory compose spec.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The new non-null `enabled` column makes it a required field on the Domain
type, so the existing traefik/compose test fixtures need it too. Adds
`enabled: true` to each base fixture (spread-based fixtures inherit it).
Fixes the apps/dokploy typecheck failure on CI.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@gentslava
gentslava force-pushed the feat/domain-enable-disable branch from a52adc6 to 0e3c228 Compare July 13, 2026 11:13
@gentslava

Copy link
Copy Markdown
Contributor Author

Thanks for the suggestion! Implemented — the redundant Enabled/Disabled text has been removed from the domain toggles.

@gentslava

Copy link
Copy Markdown
Contributor Author

@Siumauricio, could you please take a look and merge when possible? I rebased this PR onto the latest canary to avoid any new conflicts.

@narcisonunez

narcisonunez commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

@gentslava Looks good. I will be doing some tests and it everything is ok I will merge

Comment thread packages/server/src/utils/docker/domain.ts
Comment thread packages/server/src/utils/docker/domain.ts Outdated
@narcisonunez

Copy link
Copy Markdown
Collaborator

@gentslava I completed my tests. The functionality looks good. Check the last comment from geptile.

Comment thread packages/server/src/utils/docker/domain.ts Outdated
@narcisonunez

Copy link
Copy Markdown
Collaborator

@gentslava Good work.

Minor UX inconsistency: the grid-card view wraps the enable/disable switch in a explaining what it does ("Domain is active. Toggle to disable routing without deleting it." / "Domain is disabled and not routed. Toggle to enable it again."), but the table view's Status column switch has no tooltip at all. Not blocking, but worth aligning both views so the explanation is available regardless of which view the user is in.

I will approve the PR soon just doing final checks. If you want to send another commit is ok too.

@gentslava

Copy link
Copy Markdown
Contributor Author

@narcisonunez Addressed in 92b628c. The table Status switch now uses the same enabled and disabled tooltip copy as the grid-card view.

Comment thread packages/server/src/utils/docker/domain.ts
@narcisonunez

narcisonunez commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

@gentslava Recreate the migrations to fix the conflicts and we are good to approve

…e-disable

# Conflicts:
#	apps/dokploy/drizzle/meta/0182_snapshot.json
#	apps/dokploy/drizzle/meta/_journal.json
@gentslava

Copy link
Copy Markdown
Contributor Author

@narcisonunez Done — merged the latest canary, kept 0182_skinny_wild_pack from canary, and regenerated the domain enabled migration as 0183_tearful_groot. The migration snapshot/journal chain is clean and the PR is mergeable now. Typecheck and the relevant domain, Traefik, and security tests pass locally.

@narcisonunez narcisonunez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution. Good stuff

@dosubot dosubot Bot added the lgtm This PR has been approved by a maintainer label Aug 11, 2026
@narcisonunez
narcisonunez merged commit 56fdb61 into Dokploy:canary Aug 11, 2026
6 checks passed
@gentslava
gentslava deleted the feat/domain-enable-disable branch August 12, 2026 01:16
@nktnet1

nktnet1 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Resolves #4237
Resolves #4476

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: toggle to enable/disable domains without deleting them

4 participants