Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions pkg/build/buildopts.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,28 @@ func NewBuildOpts(ctx context.Context, basePath string, contextMap map[string][]
if node.Value == "COPY" || node.Value == "ADD" {
addedGlobs = append(addedGlobs, node.Next.Value)
}

// Extract source paths from bind mount flags in RUN commands
if strings.EqualFold(node.Value, "RUN") {
cmd, err := instructions.ParseInstruction(node)
if err != nil {
continue
} else if runCmd, ok := cmd.(*instructions.RunCommand); ok {
runCmd.Expand(func(word string) (string, error) {
// Single word expander to normalize source path
source := strings.TrimPrefix(word, "/")
normalized := filepath.Clean(source)
return normalized, nil
})
mounts := instructions.GetMounts(runCmd)
for _, mount := range mounts {
// Only add source paths from bind mounts (not from other stages)
if mount.Type == instructions.MountTypeBind && mount.Source != "" && mount.From == "" {
addedGlobs = append(addedGlobs, mount.Source)
}
}
}
}
}

fssyncProxy, err := fssync.NewFSSyncProxy(".", basePath, addedGlobs)
Expand Down
Loading