feat: previewDockerImage override for preview deployments#3869
Draft
kopandante wants to merge 4 commits intoDokploy:canaryfrom
Draft
feat: previewDockerImage override for preview deployments#3869kopandante wants to merge 4 commits intoDokploy:canaryfrom
kopandante wants to merge 4 commits intoDokploy:canaryfrom
Conversation
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.
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
previewDockerImageandpreviewRegistryIdfields to the application schemapreviewDockerImageis set, preview deployments pull a pre-built Docker image instead of building from source{owner},{repository},{branch},{pr_number},{app_name}previewRegistryIdfor private registry authentication (docker login)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). TheapplyPreviewDockerImagehelper mutates the in-memory object tosourceType="docker"during the preview deploy job, so existingbuildRemoteDocker/getImageName/getAuthConfighandle the rest.Changes
application.ts(schema)registry.ts(schema)application.ts(service)applyPreviewDockerImagehelper, modifieddeployPreviewApplicationandrebuildPreviewApplicationindex.ts(builders)previewRegistryinApplicationNestedtypeshow-preview-settings.tsxDepends on
Test plan
pnpm drizzle-kit generateto create migration