Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Podman Build use absolute filepath #12853

Merged
merged 1 commit into from
Jan 14, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion cmd/podman/images/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ func build(cmd *cobra.Command, args []string) error {
return errors.Wrapf(err, "error determining path to file %q", containerFiles[i])
}
contextDir = filepath.Dir(absFile)
containerFiles[i] = absFile
break
}
}
Expand Down Expand Up @@ -289,7 +290,6 @@ func build(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}

report, err := registry.ImageEngine().Build(registry.GetContext(), containerFiles, *apiBuildOpts)

if err != nil {
Expand Down
15 changes: 15 additions & 0 deletions test/e2e/build_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,4 +691,19 @@ RUN ls /dev/test1`, ALPINE)
session.WaitWithDefaultTimeout()
Expect(session).Should(Exit(0))
})

It("podman build use absolute path even if given relative", func() {
containerFile := fmt.Sprintf(`FROM %s`, ALPINE)
err = os.Mkdir("relative", 0755)
Expect(err).To(BeNil())
containerFilePath := filepath.Join("relative", "Containerfile")
fmt.Println(containerFilePath)
err = ioutil.WriteFile(containerFilePath, []byte(containerFile), 0755)
Expect(err).To(BeNil())
build := podmanTest.Podman([]string{"build", "-f", "./relative/Containerfile"})
build.WaitWithDefaultTimeout()
Expect(build).To(Exit(0))
err = os.RemoveAll("relative")
Expect(err).To(BeNil())
})
})