{"record":{"id":"fdca6534e61c46d3","repo":"slimtoolkit/slim","slug":"invalid-dockerfile-reference-s","errorCode":null,"errorMessage":"invalid dockerfile reference - %s","messagePattern":"invalid dockerfile reference - (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/app/master/builder/image_builder.go","lineNumber":117,"sourceCode":"\t\t\tTarget:         cbOpts.Target,\n\t\t\tNetworkMode:    cbOpts.NetworkMode,\n\t\t\tExtraHosts:     cbOpts.ExtraHosts,\n\t\t\tCacheFrom:      cbOpts.CacheFrom,\n\t\t\tLabels:         labels,\n\t\t\tBuildArgs:      buildArgs,\n\t\t\tRmTmpContainer: true,\n\t\t},\n\t\tAPIClient: client,\n\t}\n\n\tif strings.HasPrefix(buildContext, \"http://\") || strings.HasPrefix(buildContext, \"https://\") {\n\t\tbuilder.BuildOptions.Remote = buildContext\n\t} else {\n\t\tif exists := fsutil.DirExists(buildContext); exists {\n\t\t\tbuilder.BuildOptions.ContextDir = buildContext\n\t\t\tfullDockerfileName := filepath.Join(buildContext, cbOpts.Dockerfile)\n\t\t\tif !fsutil.Exists(fullDockerfileName) || !fsutil.IsRegularFile(fullDockerfileName) {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid dockerfile reference - %s\", fullDockerfileName)\n\t\t\t}\n\t\t} else {\n\t\t\treturn nil, ErrInvalidContextDir\n\t\t}\n\t}\n\n\tbuilder.BuildOptions.OutputStream = &builder.BuildLog\n\treturn &builder, nil\n}\n\n// Build creates a new container image\nfunc (b *BasicImageBuilder) Build() error {\n\treturn b.APIClient.BuildImage(b.BuildOptions)\n}\n\n// Remove deletes the configured container image\nfunc (b *BasicImageBuilder) Remove() error {\n\treturn nil","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/slimtoolkit/slim/blob/81940d17fa112cc678e32209214bcb2355cb3004/pkg/app/master/builder/image_builder.go#L99-L135","documentation":"NewBasicImageBuilder returns 'invalid dockerfile reference - %s' when the Dockerfile path computed inside the build context does not exist or is not a regular file. The builder joins the context directory with the Dockerfile name and validates it before building. This catches a broken Dockerfile reference before invoking a Docker build.","triggerScenarios":"NewBasicImageBuilder called with a buildContext directory that lacks cbOpts.Dockerfile, or where that path is a directory/symlink-to-nothing; buildContext exists but points to the wrong directory.","commonSituations":"Passing a custom --dockerfile-name that does not exist in the context; Dockerfile stored outside the context dir; case-sensitivity mismatch on Linux; context path pointing at an empty staging directory.","solutions":["Verify the file exists: ls <buildContext>/<Dockerfile>; fix the context dir or Dockerfile name option.","Ensure the Dockerfile is inside the build context (or copy it in before building).","Check the path is a regular file, not a directory or dangling symlink.","If a custom name is used, confirm the exact casing matches the on-disk filename."],"exampleFix":"// before\nbuilder, err := NewBasicImageBuilder(ctx, client, \"./ctx\", cbOpts) // cbOpts.Dockerfile = \"dockerfile.prod\" (missing)\n// after\ncbOpts.Dockerfile = \"Dockerfile.prod\" // must exist inside ./ctx\nbuilder, err := NewBasicImageBuilder(ctx, client, \"./ctx\", cbOpts)","handlingStrategy":"validation","validationCode":"full := filepath.Join(buildContext, cbOpts.Dockerfile)\ninfo, err := os.Stat(full)\nif err != nil || !info.Mode().IsRegular() {\n    return fmt.Errorf(\"dockerfile %s missing or not a regular file\", full)\n}","typeGuard":null,"tryCatchPattern":"builder, err := NewBasicImageBuilder(ctx, client, ctxDir, cbOpts)\nif err != nil {\n    if strings.Contains(err.Error(), \"invalid dockerfile reference\") {\n        return fmt.Errorf(\"check -c and --dockerfile: %w\", err)\n    }\n    return err\n}","preventionTips":["Confirm the Dockerfile exists inside the build context before building.","Check filename casing on Linux (case-sensitive).","Do not pass a directory where a file path is expected.","Print the resolved full path in errors to speed debugging."],"tags":["docker-build","dockerfile","builder"],"backgroundTag":"file-not-found","analyzedSha":"81940d17fa112cc678e32209214bcb2355cb3004","analyzedAt":"2026-08-31T23:06:12.682Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}