feat: add declarative apply & export commands#30
Draft
nurikk wants to merge 20 commits intoDokploy:mainfrom
Draft
feat: add declarative apply & export commands#30nurikk wants to merge 20 commits intoDokploy:mainfrom
nurikk wants to merge 20 commits intoDokploy:mainfrom
Conversation
- Use .one endpoints (application.one, postgres.one, etc.) to fetch full resource details with child resources instead of non-existent list endpoints (port.byApplicationId, redirect.byApplicationId, etc.) - Fix mount router name from 'mount' to 'mounts' (matching server registration) - Fix project ID extraction from createProject response (nested under .project) - Handle pre-existing default environment when creating projects - Fix port publishMode default from 'host' to 'ingress' (matching server behavior) - Clean up exporter to strip git-provider fields, runtime fields, and auto-created database mounts for cleaner YAML output
resolveServer() adds _resolvedServerId to config objects, but it was not in IGNORED_FIELDS. This caused spurious "update" actions for every resource with a serverName, since remote objects never contain this internal field.
- Add environment update support: executeEnvironmentAction now handles "update" actions instead of silently dropping them - Preserve schedule enabled field: stop stripping `enabled` from exports so disabled schedules survive export/apply roundtrip (use DEFAULTS to omit only when true) - Narrow mount duplicate detection: only swallow 409 or 400 with "already" message, not all 400 errors - Guard createProject response: throw immediately if projectId is missing instead of propagating undefined
Move the API client from src/lib/apply/api-client.ts to src/utils/api.ts so it can serve as the canonical HTTP layer for the entire CLI, not just the apply/export commands. - src/utils/api.ts: canonical location with trpcQuery/trpcMutation helpers - src/lib/apply/api-client.ts: re-exports from utils/api for compatibility - src/utils/shared.ts: rewritten to use api client instead of raw axios - src/lib/apply/exporter.ts: removed duplicate fetchProject function
All 30 command files now use src/utils/api.ts instead of direct axios calls. axios is imported in exactly one place. - Migrated: authenticate, verify, project/create, environment/create, environment/delete, env/push, app/* (4 files), database/*/* (20 files) - Added lifecycle endpoints to api.ts: deploy, stop, remove for all service types; getUser for auth validation - Removed unused src/utils/http.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds two new commands to the Dokploy CLI for managing resources as code (ref: Dokploy/dokploy#3872, Dokploy/dokploy#4008):
dokploy apply -f dokploy.yaml— Apply a declarative YAML config to create or update resources on the serverdokploy export -p <project> -f out.yaml— Export an existing project as adokploy.yamlconfig fileThese commands enable round-tripping: export a project, check the YAML into git, modify it, and apply changes back.
applycommandserverNamefield for multi-server deploymentsdokploy env pushexportcommandapplyschema exactly (round-trip safe)Architecture
New dependencies
yaml— YAML parsing and serializationzod— Schema validationTest plan
--helpcommands render correctly