Skip to content

Commit

Permalink
use Dockerfile-specific ignore-file when present
Browse files Browse the repository at this point in the history
  • Loading branch information
Jancis committed Dec 3, 2024
1 parent 7e6532c commit 4c6416c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cmd/ciImageBuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <dockerfile>.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 {
Expand Down
4 changes: 4 additions & 0 deletions cmd/ciImageUrl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 <dockerfile>.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 {
Expand Down

0 comments on commit 4c6416c

Please sign in to comment.