fix(server): default docker build context to repo root for dockerfile builds - #4958
Open
azizbecha wants to merge 2 commits into
Open
fix(server): default docker build context to repo root for dockerfile builds#4958azizbecha wants to merge 2 commits into
azizbecha wants to merge 2 commits into
Conversation
… builds When the Docker Context Path field was empty, the build context defaulted to the directory containing the Dockerfile instead of the cloned repo root, breaking COPY instructions that reference files outside the Dockerfile's directory. The UI placeholder already advertises "." (repo root) as the default. getDockerContextPath now always returns a path, falling back to the code root, and resolves it against buildServerId || serverId to match getBuildAppDirectory so the context is correct on remote build servers.
…o root The previous commit defaulted the context to the repo code root, which broke Dockerfiles that live inside a build path and COPY files relative to it (e.g. the examples repo's deno app with customGitBuildPath /deno). Extract the per-sourceType build path resolution from getBuildAppDirectory into getBuildPath and reuse it in getDockerContextPath, so an empty Docker Context Path now defaults to <code>/<buildPath>. With no build path set this is still the repo root, which keeps the original fix for Dockerfiles in subfolders.
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.
What is this PR about?
When the Docker Context Path field is left empty for a Dockerfile deployment, the build context defaults to the directory containing the Dockerfile instead of the cloned repository root — even though the UI placeholder advertises
(default: .). With a Dockerfile in a subfolder (e.g.docker/Dockerfile), anyCOPYreferencing files outside that subfolder fails with "not found".There was also an inconsistency: a filled-in context path resolves relative to the repo root (
code/), while the empty-field fallback resolved relative to the Dockerfile's directory — two different bases.Changes:
getDockerContextPathnow always returns a path, falling back to the repo code root when the field is empty, so the default matches both the UI placeholder and standarddocker build .convention.buildServerId || serverId(matchinggetBuildAppDirectory), so the context path is also correct when building on a remote build server.getDockerCommanddrops its Dockerfile-directory fallback; the-fflag already passes the absolute Dockerfile path, so Dockerfiles in subfolders are still found.Checklist
Before submitting this PR, please make sure that:
canarybranch.Verified with
pnpm typecheckonpackages/serverand thedocker-build-injectiontest suite (4/4 passing).Issues related (if applicable)
N/A
Screenshots (if applicable)
N/A
Greptile Summary
The PR changes Dockerfile builds so an empty Docker context resolves to an absolute source-tree path and aligns path selection with remote build-server execution.
getBuildPath.getDockerContextPathreturn a concrete path for empty values.Confidence Score: 5/5
The PR appears safe to merge within the scope of this follow-up review.
No blocking failure remains among eligible new comments or previously reported findings.
Reviews (2): Last reviewed commit: "fix(server): default docker context to b..." | Re-trigger Greptile
Context used: