Repository: docker/compose
File: pkg/compose/build_bake.go (Go)

Code before:
	if build.Provenance != "" {
		if build.Provenance == "true" {
			attests = append(attests, "type=provenance")
		} else if build.Provenance != "false" {
			attests = append(attests, fmt.Sprintf("type=provenance,%s", build.Provenance))
		}
	}

	// Handle per-service SBOM configuration (only from build config, not global options)
	if build.SBOM != "" {
		if build.SBOM == "true" {
			attests = append(attests, "type=sbom")
		} else if build.SBOM != "false" {
			attests = append(attests, fmt.Sprintf("type=sbom,%s", build.SBOM))
		}
	}

	return attests
}

func dockerFilePath(ctxName string, dockerfile string) string {
	if dockerfile == "" {
		return ""
	}
	// TODO(thaJeztah): remove uses of urlutil and only conditionally call this dockerFilePath utility
	if urlutil.IsGitURL(ctxName) {
		return dockerfile
	}
	if !filepath.IsAbs(dockerfile) {
		dockerfile = filepath.Join(ctxName, dockerfile)
	}
	dir := filepath.Dir(dockerfile)
	symlinks, err := filepath.EvalSymlinks(dir)
	if err == nil {
		return filepath.Join(symlinks, filepath.Base(dockerfile))
	}
	return dockerfile
}

func dryRunBake(ctx context.Context, cfg bakeConfig) map[string]string {
	w := progress.ContextWriter(ctx)
	bakeResponse := map[string]string{}
	for name, target := range cfg.Targets {
		dryRunUUID := fmt.Sprintf("dryRun-%x", sha1.Sum([]byte(name)))
		displayDryRunBuildEvent(w, name, dryRunUUID, target.Tags[0])
		bakeResponse[name] = dryRunUUID
	}
	for name := range bakeResponse {
		w.Event(progress.BuiltEvent(name))
	}
	return bakeResponse

Review comment (suggestion):
Maybe I should just use `build.DetectContextType(ctxName)` here, and check for `build.ContextTypeGit` 🤔 

Code after:
	if build.Provenance != "" {
		if build.Provenance == "true" {
			attests = append(attests, "type=provenance")
		} else if build.Provenance != "false" {
			attests = append(attests, fmt.Sprintf("type=provenance,%s", build.Provenance))
		}
	}

	// Handle per-service SBOM configuration (only from build config, not global options)
	if build.SBOM != "" {
		if build.SBOM == "true" {
			attests = append(attests, "type=sbom")
		} else if build.SBOM != "false" {
			attests = append(attests, fmt.Sprintf("type=sbom,%s", build.SBOM))
		}
	}

	return attests
}

func dockerFilePath(ctxName string, dockerfile string) string {
	if dockerfile == "" {
		return ""
	}
	if contextType, _ := build.DetectContextType(ctxName); contextType == build.ContextTypeGit {
		return dockerfile
	}
	if !filepath.IsAbs(dockerfile) {
		dockerfile = filepath.Join(ctxName, dockerfile)
	}
	dir := filepath.Dir(dockerfile)
	symlinks, err := filepath.EvalSymlinks(dir)
	if err == nil {
		return filepath.Join(symlinks, filepath.Base(dockerfile))
	}
	return dockerfile
}

func dryRunBake(ctx context.Context, cfg bakeConfig) map[string]string {
	w := progress.ContextWriter(ctx)
	bakeResponse := map[string]string{}
	for name, target := range cfg.Targets {
		dryRunUUID := fmt.Sprintf("dryRun-%x", sha1.Sum([]byte(name)))
		displayDryRunBuildEvent(w, name, dryRunUUID, target.Tags[0])
		bakeResponse[name] = dryRunUUID
	}
	for name := range bakeResponse {
		w.Event(progress.BuiltEvent(name))
	}
	return bakeResponse
}