Skip to content

fix(server): default docker build context to repo root for dockerfile builds - #4958

Open
azizbecha wants to merge 2 commits into
Dokploy:canaryfrom
azizbecha:fix/docker-context-path-default
Open

fix(server): default docker build context to repo root for dockerfile builds#4958
azizbecha wants to merge 2 commits into
Dokploy:canaryfrom
azizbecha:fix/docker-context-path-default

Conversation

@azizbecha

@azizbecha azizbecha commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

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), any COPY referencing 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:

  • getDockerContextPath now 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 standard docker build . convention.
  • It now resolves paths using buildServerId || serverId (matching getBuildAppDirectory), so the context path is also correct when building on a remote build server.
  • getDockerCommand drops its Dockerfile-directory fallback; the -f flag already passes the absolute Dockerfile path, so Dockerfiles in subfolders are still found.

Checklist

Before submitting this PR, please make sure that:

  • You created a dedicated branch based on the canary branch.
  • You have read the suggestions in the CONTRIBUTING.md file https://github.com/Dokploy/dokploy/blob/canary/CONTRIBUTING.md#pull-request
  • You have tested this PR in your local instance. If you have not tested it yet, please do so before submitting. This helps avoid wasting maintainers' time reviewing code that has not been verified by you.

Verified with pnpm typecheck on packages/server and the docker-build-injection test 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.

  • Extracts provider-specific build-path selection into getBuildPath.
  • Makes getDockerContextPath return a concrete path for empty values.
  • Removes the Dockerfile-directory fallback from Docker command generation.

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:

… 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.
@azizbecha
azizbecha requested a review from Siumauricio as a code owner August 3, 2026 02:09
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. bug Something isn't working labels Aug 3, 2026
…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.
@dosubot dosubot Bot added size:M This PR changes 30-99 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant