mirror of https://github.com/containers/podman.git
Podman Build use absolute filepath
podman build always finds the abs path but was never using it for the containerfile path. This was causing the remote client to be given a relative path that does not exist. Switch to evaluating and using absolute paths only. resolves #12841 Signed-off-by: cdoern <cdoern@redhat.com>
This commit is contained in:
parent
2c510146aa
commit
bf3734ad53
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
|
|
|
@ -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())
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue