make path to Dockerfile an absolute path (#228)
* make path to dockerfile an absolute path * refactored checking dockerfile path
This commit is contained in:
parent
19287f89c5
commit
dbdf116f8c
|
|
@ -86,7 +86,7 @@ var RootCmd = &cobra.Command{
|
|||
os.Exit(1)
|
||||
}
|
||||
ref, image, err := executor.DoBuild(executor.KanikoBuildArgs{
|
||||
DockerfilePath: dockerfilePath,
|
||||
DockerfilePath: absouteDockerfilePath(),
|
||||
SrcContext: srcContext,
|
||||
SnapshotMode: snapshotMode,
|
||||
Args: buildArgs,
|
||||
|
|
@ -113,16 +113,28 @@ func checkContained() bool {
|
|||
|
||||
func checkDockerfilePath() error {
|
||||
if util.FilepathExists(dockerfilePath) {
|
||||
if _, err := filepath.Abs(dockerfilePath); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// Otherwise, check if the path relative to the build context exists
|
||||
if util.FilepathExists(filepath.Join(srcContext, dockerfilePath)) {
|
||||
dockerfilePath = filepath.Join(srcContext, dockerfilePath)
|
||||
return nil
|
||||
}
|
||||
return errors.New("please provide a valid path to a Dockerfile within the build context")
|
||||
}
|
||||
|
||||
func absouteDockerfilePath() string {
|
||||
if util.FilepathExists(dockerfilePath) {
|
||||
// Ignore error since we already checked it in checkDockerfilePath()
|
||||
abs, _ := filepath.Abs(dockerfilePath)
|
||||
return abs
|
||||
}
|
||||
// Otherwise, return path relative to build context
|
||||
return filepath.Join(srcContext, dockerfilePath)
|
||||
}
|
||||
|
||||
// resolveSourceContext unpacks the source context if it is a tar in a bucket
|
||||
// it resets srcContext to be the path to the unpacked build context within the image
|
||||
func resolveSourceContext() error {
|
||||
|
|
|
|||
Loading…
Reference in New Issue