MCPcopy
hub / github.com/docker/compose / LoadDockerIgnore

Function LoadDockerIgnore

pkg/watch/dockerignore.go:68–98  ·  view source on GitHub ↗
(build *types.BuildConfig)

Source from the content-addressed store, hash-verified

66}
67
68func LoadDockerIgnore(build *types.BuildConfig) (PathMatcher, error) {
69 if build == nil {
70 return EmptyMatcher{}, nil
71 }
72 repoRoot := build.Context
73 absRoot, err := filepath.Abs(repoRoot)
74 if err != nil {
75 return nil, err
76 }
77
78 // first try Dockerfile-specific ignore-file
79 f, err := os.Open(filepath.Join(repoRoot, build.Dockerfile+".dockerignore"))
80 if os.IsNotExist(err) {
81 // defaults to a global .dockerignore
82 f, err = os.Open(filepath.Join(repoRoot, ".dockerignore"))
83 if os.IsNotExist(err) {
84 return NewDockerPatternMatcher(repoRoot, nil)
85 }
86 }
87 if err != nil {
88 return nil, err
89 }
90 defer func() { _ = f.Close() }()
91
92 patterns, err := readDockerignorePatterns(f)
93 if err != nil {
94 return nil, err
95 }
96
97 return NewDockerPatternMatcher(absRoot, patterns)
98}
99
100// Make all the patterns use absolute paths.
101func absPatterns(absRoot string, patterns []string) []string {

Callers 2

getWatchRulesFunction · 0.92
initialSyncMethod · 0.92

Calls 3

NewDockerPatternMatcherFunction · 0.85
readDockerignorePatternsFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…