Skip to content

Commit 73e8800

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

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

envbuilder.go

+9
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,15 @@ 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", dockerfilePath, options.WorkspaceFolder)
480+
logf(codersdk.LogLevelWarn, "\t-> set BUILD_CONTEXT_PATH to %q to fix", dockerfileDir)
481+
}
482+
474483
dockerfile, err := options.Filesystem.Open(dockerfilePath)
475484
if err == nil {
476485
content, err := io.ReadAll(dockerfile)

0 commit comments

Comments
 (0)