Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit 9e641b4

Browse files
author
Priya Wadhwa
committed
fixed bug in copy
1 parent 7dbc7a0 commit 9e641b4

4 files changed

Lines changed: 8 additions & 3 deletions

File tree

integration_tests/dockerfiles/Dockerfile_test_multistage

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ FROM gcr.io/distroless/base:latest
22
COPY . .
33

44
FROM scratch as second
5-
COPY --from=0 context/foo /foo
5+
ENV foopath context/foo
6+
COPY --from=0 $foopath context/b* /foo/
67

78
FROM gcr.io/distroless/base:latest
89
COPY --from=second /foo /foo2

pkg/commands/copy.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ func (c *CopyCommand) ExecuteCommand(config *manifest.Schema2Config) error {
7373
}
7474
if fi.IsDir() {
7575
if !filepath.IsAbs(dest) {
76-
dest = filepath.Join(cwd, dest)
76+
// we need to add '/' to the end to indicate the destination is a directory
77+
dest = filepath.Join(cwd, dest) + "/"
7778
}
7879
if err := util.CopyDir(fullPath, dest); err != nil {
7980
return err

pkg/dockerfile/dockerfile.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func Parse(b []byte) ([]instructions.Stage, error) {
4242
return stages, err
4343
}
4444

45-
// ResolveStages resolves any calls to previous stages to the number value of that stage
45+
// ResolveStages resolves any calls to previous stages with names to indices
4646
// Ex. --from=second_stage should be --from=1 for easier processing later on
4747
func ResolveStages(stages []instructions.Stage) {
4848
nameToIndex := make(map[string]string)

pkg/util/fs_util.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ func RelativeFiles(fp string, root string) ([]string, error) {
144144
fullPath := filepath.Join(root, fp)
145145
logrus.Debugf("Getting files and contents at root %s", fullPath)
146146
err := filepath.Walk(fullPath, func(path string, info os.FileInfo, err error) error {
147+
if PathInWhitelist(path, root) {
148+
return nil
149+
}
147150
if err != nil {
148151
return err
149152
}

0 commit comments

Comments
 (0)