fix: use buildServerId for preview deployments#3781
Closed
kopandante wants to merge 1 commit intoDokploy:canaryfrom
Closed
fix: use buildServerId for preview deployments#3781kopandante wants to merge 1 commit intoDokploy:canaryfrom
kopandante wants to merge 1 commit intoDokploy:canaryfrom
Conversation
Preview deployments now respect the buildServerId configuration, matching the behavior of production deployments. Previously, preview builds always ran on the application server (serverId), ignoring any configured build server. Changes: - deployPreviewApplication: use buildServerId || serverId for build execution - rebuildPreviewApplication: same fix (catch block already had it) - createDeploymentPreview: resolve buildServerId for log path and remote exec, store buildServerId in deployment record Fixes Dokploy#3450
| await removeLastTenDeployments( | ||
| deployment.previewDeploymentId, | ||
| "previewDeployment", | ||
| previewDeployment?.application?.serverId, |
Contributor
There was a problem hiding this comment.
should use buildServerId instead of serverId for consistency
old logs will be cleaned up from the wrong server if buildServerId is different from serverId
Suggested change
| previewDeployment?.application?.serverId, | |
| buildServerId, |
This was referenced Feb 23, 2026
Author
|
Superseded by #3784 |
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.
Problem
Preview deployments always build on the application server (
serverId), ignoring the configured build server (buildServerId). This is inconsistent with production deployments, which correctly usebuildServerId || serverId.This means users who set up a separate build server to offload resource-intensive builds still have preview builds running on their production server, potentially causing memory pressure and OOM issues.
Related issues: #3450
Root Cause
In
packages/server/src/services/application.ts:deployPreviewApplication()usesapplication.serverIddirectlyrebuildPreviewApplication()usesapplication.serverIdin the try block (interestingly, the catch block already uses the correctapplication.buildServerId || application.serverIdpattern)In
packages/server/src/services/deployment.ts:createDeploymentPreview()usespreviewDeployment.application.serverIdfor log path resolution and remote execution, and does not storebuildServerIdin the deployment recordMeanwhile, their production counterparts (
deployApplication()andcreateDeployment()) correctly use thebuildServerId || serverIdfallback pattern.Changes
packages/server/src/services/application.ts:deployPreviewApplication(): resolvebuildServerId || serverIdbefore executing the build command remotelyrebuildPreviewApplication(): changeconst serverId = application.serverIdtoconst serverId = application.buildServerId || application.serverId(aligns try block with existing catch block)packages/server/src/services/deployment.ts:createDeploymentPreview(): resolvebuildServerIdfrom the application, use it forpaths(),findServerById(), andexecAsyncRemote(). StorebuildServerIdin the deployment record (matchingcreateDeployment()behavior)Behavior
buildServerIdis configured: preview builds run on the build serverbuildServerIdis not configured: no change, builds run on the application server (same as before)Testing
Tested on a Dokploy v0.27.0 instance with a separate build server configured. Preview deployments now correctly execute on the build server and logs are written to the correct remote path.
Greptile Summary
This PR correctly fixes preview deployments to respect the
buildServerIdconfiguration, aligning them with production deployment behavior. The changes ensure that when a separate build server is configured, preview builds execute on that server instead of incorrectly running on the application server.Key changes:
deployPreviewApplication(): now resolvesbuildServerId || serverIdbefore remote executionrebuildPreviewApplication(): changed to usebuildServerId || serverIdconsistently in both try and catch blockscreateDeploymentPreview(): resolvesbuildServerIdfor log paths, remote execution, and stores it in deployment recordsMinor issue found:
deployment.tsstill passesserverIdtoremoveLastTenDeployments()instead ofbuildServerId, which could cause old logs to be cleaned up from the wrong serverConfidence Score: 4/5
buildServerIdsupport for preview deployments and align well with the existing production deployment patterns. The logic is sound and the implementation is consistent. However, there's one logical issue at line 171 where old log cleanup usesserverIdinstead ofbuildServerId, which could cause logs to be deleted from the wrong server. This should be fixed before merging to ensure complete correctness.packages/server/src/services/deployment.tsline 171Last reviewed commit: 1e56fe7
(2/5) Greptile learns from your feedback when you react with thumbs up/down!