diff --git a/cmd/ciImageBuild.go b/cmd/ciImageBuild.go index 2623f57..6568a66 100644 --- a/cmd/ciImageBuild.go +++ b/cmd/ciImageBuild.go @@ -56,6 +56,10 @@ var ciImageBuildCmd = &cobra.Command{ if _, err := os.Stat(fmt.Sprintf("%s/.dockerignore", buildPath)); err == nil { excludeDockerignore = fmt.Sprintf("--exclude-from='%s'/.dockerignore", buildPath) } + // use .dockerignore if exists, later takes precedence + if _, err := os.Stat(fmt.Sprintf("%s.dockerignore", dockerfile)); err == nil { + excludeDockerignore = fmt.Sprintf("--exclude-from='%s.dockerignore'", dockerfile) + } // If no path is specified, build from an empty directory if len(buildPath) == 0 { diff --git a/cmd/ciImageUrl.go b/cmd/ciImageUrl.go index 538963c..f9984b1 100644 --- a/cmd/ciImageUrl.go +++ b/cmd/ciImageUrl.go @@ -49,6 +49,10 @@ var ciImageUrlCmd = &cobra.Command{ if _, err := os.Stat(fmt.Sprintf("%s/.dockerignore", buildPath)); err == nil { excludeDockerignore = fmt.Sprintf("--exclude-from='%s'/.dockerignore", buildPath) } + // use .dockerignore if exists, later takes precedence + if _, err := os.Stat(fmt.Sprintf("%s.dockerignore", dockerfile)); err == nil { + excludeDockerignore = fmt.Sprintf("--exclude-from='%s.dockerignore'", dockerfile) + } // If no path is specified, build from an empty directory if len(buildPath) == 0 {