{"id":16934418,"url":"https://github.com/codeskyblue/dockerignore","last_synced_at":"2025-08-22T00:49:44.656Z","repository":{"id":57482898,"uuid":"47953257","full_name":"codeskyblue/dockerignore","owner":"codeskyblue","description":"go library parse gitignore file, source code most from docker","archived":false,"fork":false,"pushed_at":"2016-06-22T15:13:31.000Z","size":20,"stargazers_count":13,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-25T14:44:47.550Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codeskyblue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-14T05:07:52.000Z","updated_at":"2023-07-06T19:42:59.000Z","dependencies_parsed_at":"2022-09-26T17:50:36.846Z","dependency_job_id":null,"html_url":"https://github.com/codeskyblue/dockerignore","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Fdockerignore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Fdockerignore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Fdockerignore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codeskyblue%2Fdockerignore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codeskyblue","download_url":"https://codeload.github.com/codeskyblue/dockerignore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248464370,"owners_count":21108238,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-13T20:52:03.553Z","updated_at":"2025-04-11T18:52:16.606Z","avatar_url":"https://github.com/codeskyblue.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dockerignore\n[![GoDoc](https://godoc.org/github.com/codeskyblue/dockerignore?status.svg)](https://godoc.org/github.com/codeskyblue/dockerignore)\n\ngo library parse gitignore file, source code most from [docker](https://github.com/docker/docker)\n\n## Usage\n```go\npackage main\n\nimport (\n    \"bytes\"\n    \"io/ioutil\"\n    \"log\"\n\n    ignore \"github.com/codeskyblue/dockerignore\"\n)\n\nfunc main() {\n    // patterns, err := ignore.ReadIgnoreFile(\".gitignore\")\n    rd := ioutil.NopCloser(bytes.NewBufferString(\"*.exe\"))\n    patterns, err := ignore.ReadIgnore(rd)\n    if err != nil {\n        log.Fatal(err)\n    }   \n    isSkip, err := ignore.Matches(\"hello.exe\", patterns)\n    if err != nil {\n        log.Fatal(err)\n    }   \n    log.Printf(\"Should skipped true, got %v\", isSkip)\n}\n```\n\n## Rules\nThe Go lib interprets a `.dockerignore` like file as a newline-separated list of patterns similar to the file globs of Unix shells. \nFor the purposes of matching, the root of the context is considered to be both the working and the root directory. \nFor example, the patterns /foo/bar and foo/bar both exclude a file or directory named bar in the foo subdirectory of PATH or in the root of the git repository located at URL. \nNeither excludes anything else.\n\nHere is an example .dockerignore file:\n\n    */temp*\n    */*/temp*\n    temp?\n\nThis file causes the following build behavior:\n\nRule        | Behavior\n------------|----------\n`*/temp*`   | Exclude files and directories whose names start with temp in any immediate subdirectory of the root. For example, the plain file `/somedir/temporary.txt` is excluded, as is the directory `/somedir/temp`.\n`*/*/temp*` | Exclude files and directories starting with temp from any subdirectory that is two levels below the root. For example, `/somedir/subdir/temporary.txt` is excluded.\n`temp?`     | Exclude files and directories in the root directory whose names are a one-character extension of temp. For example, `/tempa` and `/tempb` are excluded.\n\nMatching is done using Go’s filepath.Match rules. \nA preprocessing step removes leading and trailing whitespace and eliminates `.` and `..` elements using Go’s filepath.Clean. \nLines that are blank after preprocessing are ignored.\n\nLines starting with `!` (exclamation mark) can be used to make exceptions to exclusions.\nThe following is an example `.dockerignore` file that uses this mechanism:\n\n    *.md\n    !README.md\n\nAll markdown files except `README.md` are excluded from the context.\n\nThe placement of `!` exception rules influences the behavior: the last line of the `.dockerignore` that matches a particular file determines whether it is included or excluded. \nConsider the following example:\n\n    *.md\n    !README*.md\n    README-secret.md\n\nNo markdown files are included in the context except README files other than `README-secret.md`\n\nNow consider this example:\n\n    *.md\n    README-secret.md\n    !README*.md\n\nAll of the README files are included.\nThe middle line has no effect because `!README*.md` matches `README-secret.md` and comes last.\n\nYou can even use the `.dockerignore` file to exclude the Dockerfile and `.dockerignore` files.\nThese files are still sent to the daemon because it needs them to do its job.\nBut the ADD and COPY commands do not copy them to the the image.\n\nFinally, you may want to specify which files to include in the context, rather than which to exclude.\nTo achieve this, specify `*` as the first pattern, followed by one or more `!` exception patterns.\n\nNote: For historical reasons, the pattern `.` is ignored.\n\n## LICENCE\nFolow the docker license, this lib use [APACHE V2 LICENSE](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeskyblue%2Fdockerignore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodeskyblue%2Fdockerignore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodeskyblue%2Fdockerignore/lists"}