Skip to content

feat: add sync pull/diff/push commands#21

Open
iamtoled wants to merge 2 commits intoDokploy:mainfrom
iamtoled:feat/sync-commands
Open

feat: add sync pull/diff/push commands#21
iamtoled wants to merge 2 commits intoDokploy:mainfrom
iamtoled:feat/sync-commands

Conversation

@iamtoled
Copy link

Summary

  • Adds dokploy sync pull / dokploy sync diff / dokploy sync push commands for an infrastructure-as-code workflow
  • Serializes full Dokploy state (projects, environments, applications, compose, all 5 database types + their domains/ports/mounts/redirects/security) to local YAML files
  • Diffs local YAML against the live server with colored field-level output
  • Pushes changed fields back via tRPC .update endpoints (update-only in v1, no create/delete)
  • Supports --project filter, --redact for sensitive fields, --dry-run, and --yes to skip confirmation
  • Fixes pre-existing build error in database/redis/create.ts (missing environmentId destructure)

New files

File Purpose
src/utils/sync/types.ts Normalized state types for all resource kinds
src/utils/sync/constants.ts Ephemeral/sensitive field lists, DB type mappings
src/utils/sync/fetch-state.ts Fetches full state via project.all + *.one per resource (batched 10 concurrent)
src/utils/sync/yaml-io.ts YAML read/write with slugified directory names and collision avoidance
src/utils/sync/redact.ts Recursive redaction of password/env/token fields
src/utils/sync/diff.ts Deep-equal diff by resource ID with colored terminal formatting
src/utils/sync/apply.ts Builds update plan from diffs, maps resource types to tRPC endpoints
src/commands/sync/pull.ts sync pull command
src/commands/sync/diff.ts sync diff command
src/commands/sync/push.ts sync push command

YAML output structure

dokploy-state/
  projects/
    {slugified-name}/
      project.yaml
      environments/
        {slugified-name}/
          environment.yaml
          applications/
            {slugified-name}.yaml
          compose/
            {slugified-name}.yaml
          databases/
            {slugified-name}.yaml    # has type: postgres|mysql|... discriminator

v1 scope

  • Pull/diff/push for projects, environments, applications, compose, all 5 DB types
  • Sub-resources included: domains, ports, mounts, redirects, security
  • Update existing resources only on push (create/delete deferred to v2)

Test plan

  • pnpm build compiles clean
  • dokploy sync pull against a live instance - check YAML output structure
  • dokploy sync pull --redact - sensitive fields masked
  • Edit a YAML field, run dokploy sync diff - should show the change
  • dokploy sync push --dry-run - should show planned update without applying
  • dokploy sync push - should apply and confirm
  • dokploy sync pull again - should show updated value

🤖 Generated with Claude Code

…kflow

Adds three new commands under `dokploy sync` that serialize Dokploy server
state to local YAML files, diff local vs. remote, and push local changes back.

- `sync pull` - fetches full state and writes YAML files to disk
- `sync diff` - compares local YAML against live server with colored output
- `sync push` - applies local changes via tRPC update endpoints (update-only)

Supports --project filter, --redact for sensitive fields, --dry-run, and --yes.
Also fixes pre-existing build error in database/redis/create.ts (missing
environmentId destructure).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
28 tests covering:
- redact: sensitive field masking, nested objects, arrays, null handling
- diff: identical states, field modifications, added/removed resources,
  ephemeral field skipping, redacted field skipping
- apply: update plan building, skip create/delete, redacted field filtering,
  all 5 database type endpoint mapping
- yaml-io: round-trip serialization, ephemeral stripping, redaction,
  directory structure, empty dirs, name collision handling

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments