Skip to content

Commit 4dbe75b

Browse files
committed
Add warning
Signed-off-by: Danny Kopping <[email protected]>
1 parent 0643d17 commit 4dbe75b

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

envbuilder.go

+8
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,14 @@ func Run(ctx context.Context, options Options) error {
471471
} else {
472472
// If a Dockerfile was specified, we use that.
473473
dockerfilePath := filepath.Join(options.WorkspaceFolder, options.DockerfilePath)
474+
475+
// If the dockerfilePath is specified and deeper than the base of WorkspaceFolder AND the BuildContextPath is
476+
// not defined, show a warning
477+
dockerfileDir := filepath.Dir(dockerfilePath)
478+
if dockerfileDir != filepath.Clean(options.WorkspaceFolder) && options.BuildContextPath == "" {
479+
logf(codersdk.LogLevelWarn, "given dockerfile %q is below %q and no custom build context has been defined; set BUILD_CONTEXT_PATH to %q to fix", dockerfilePath, options.WorkspaceFolder, dockerfileDir)
480+
}
481+
474482
dockerfile, err := options.Filesystem.Open(dockerfilePath)
475483
if err == nil {
476484
content, err := io.ReadAll(dockerfile)

0 commit comments

Comments
 (0)