Skip to content

feat: previewDockerImage override for preview deployments#3869

Draft
kopandante wants to merge 4 commits intoDokploy:canaryfrom
kopandante:feat/preview-docker-image
Draft

feat: previewDockerImage override for preview deployments#3869
kopandante wants to merge 4 commits intoDokploy:canaryfrom
kopandante:feat/preview-docker-image

Conversation

@kopandante
Copy link

@kopandante kopandante commented Mar 3, 2026

Summary

  • Add previewDockerImage and previewRegistryId fields to the application schema
  • When previewDockerImage is set, preview deployments pull a pre-built Docker image instead of building from source
  • Template variables: {owner}, {repository}, {branch}, {pr_number}, {app_name}
  • Optional previewRegistryId for private registry authentication (docker login)
  • UI: Docker Image input + conditional Registry select in Preview Deployment Settings

Motivation

For integration with external CI (GitHub Actions, Blacksmith, etc). The CI builds and pushes the image to a registry (e.g. ghcr.io), then Dokploy preview just pulls it -- faster deploys, no build server load.

Design

The application stays sourceType="github" in the DB (webhooks work unchanged). The applyPreviewDockerImage helper mutates the in-memory object to sourceType="docker" during the preview deploy job, so existing buildRemoteDocker/getImageName/getAuthConfig handle the rest.

Changes

File What
application.ts (schema) +2 nullable columns, +1 relation, +2 Zod fields
registry.ts (schema) +1 reverse relation
application.ts (service) +applyPreviewDockerImage helper, modified deployPreviewApplication and rebuildPreviewApplication
index.ts (builders) +previewRegistry in ApplicationNested type
show-preview-settings.tsx +Docker Image input with template tooltip, +conditional Registry select

Depends on

Test plan

  • Run pnpm drizzle-kit generate to create migration
  • Verify existing preview deployments work unchanged (previewDockerImage = null)
  • Set previewDockerImage on an app, create PR, verify preview pulls image
  • Test with private registry (previewRegistryId set)
  • Test clearing docker image field reverts to build-from-source behavior

Preview deployments ignored the buildServerId configuration, causing
four issues when a separate build server was configured:

1. buildRegistry was unconditionally nulled, breaking registry auth
   for image push/pull between build and deploy servers

2. Build commands ran on serverId instead of buildServerId, so the
   build executed on the deploy server instead of the build server

3. docker.createService() did not pass authconfig as a separate
   argument (unlike service.update()), so Swarm could not pull
   images from authenticated registries

4. Log directory was created on the deploy server while the build
   ran on the build server, causing "file not found" errors

These fixes align preview deployment behavior with the regular
deployment flow (deployApplication/rebuildApplication) which already
correctly uses buildServerId.
Allow preview deployments to pull a pre-built Docker image instead of
building from source. When `previewDockerImage` is set on an application,
the preview deploy resolves the template (supports {owner}, {repository},
{branch}, {pr_number}, {app_name}) and uses `buildRemoteDocker` to pull
the image, skipping clone+build entirely.

New fields:
- `previewDockerImage`: image template (e.g. ghcr.io/{owner}/{repo}:pr-{pr_number})
- `previewRegistryId`: FK to registry for docker login credentials

The application remains sourceType="github" in the DB (webhooks work
unchanged). The sourceType is mutated to "docker" only in-memory during
the preview deploy job.
Also fix pullRequestNumber type (string, not number) in
applyPreviewDockerImage to match the preview_deployments schema.
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