{"id":19546016,"url":"https://github.com/hewlettpackard/dockerfile-parser-rs","last_synced_at":"2025-07-06T12:07:02.887Z","repository":{"id":43169485,"uuid":"249842711","full_name":"HewlettPackard/dockerfile-parser-rs","owner":"HewlettPackard","description":"a Rust library for parsing, validating, and modifying Dockerfiles","archived":false,"fork":false,"pushed_at":"2024-10-31T22:02:17.000Z","size":113,"stargazers_count":50,"open_issues_count":11,"forks_count":15,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-07-06T12:07:02.020Z","etag":null,"topics":["dockerfile","parser","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/HewlettPackard.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-24T23:43:24.000Z","updated_at":"2025-06-23T19:45:19.000Z","dependencies_parsed_at":"2024-11-11T03:42:45.096Z","dependency_job_id":"f87368cb-674d-4f01-aeaf-e46db4cd2f8e","html_url":"https://github.com/HewlettPackard/dockerfile-parser-rs","commit_stats":{"total_commits":44,"total_committers":6,"mean_commits":7.333333333333333,"dds":"0.38636363636363635","last_synced_commit":"e974fa5b04c4d94f51e2830644488e50c67b9b33"},"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"purl":"pkg:github/HewlettPackard/dockerfile-parser-rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HewlettPackard%2Fdockerfile-parser-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HewlettPackard%2Fdockerfile-parser-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HewlettPackard%2Fdockerfile-parser-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HewlettPackard%2Fdockerfile-parser-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HewlettPackard","download_url":"https://codeload.github.com/HewlettPackard/dockerfile-parser-rs/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HewlettPackard%2Fdockerfile-parser-rs/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263897981,"owners_count":23526832,"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":["dockerfile","parser","rust"],"created_at":"2024-11-11T03:42:39.105Z","updated_at":"2025-07-06T12:07:02.847Z","avatar_url":"https://github.com/HewlettPackard.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dockerfile-parser-rs\n\n[![docs.rs](https://docs.rs/dockerfile-parser/badge.svg)](https://docs.rs/dockerfile-parser/)\n\nA pure Rust library for parsing and inspecting Dockerfiles, useful for\nperforming static analysis, writing linters, and creating automated tooling\naround Dockerfiles. It uses a proper grammar and can provide useful syntax\nerrors in addition to a full syntax tree.\n\n## Limitations\n\n * Buildkit parser directives are not handled at all.\n * Unknown instructions are parsed as `MiscInstruction` rather than producing\n   an explicit error. A number of valid but less interesting Docker instructions\n   are handled this way, e.g. `ONBUILD`, `MAINTAINER`, etc. See notes in\n   [the grammar](./src/dockerfile_parser.pest) for details.\n\n## Usage\n\nSee [`./examples`](./examples) for a few usage examples, including a small\nutility to dump a Dockerfile's structure:\n\n```bash\n$ cargo run --example stages Dockerfile.test\n    Finished dev [unoptimized + debuginfo] target(s) in 0.03s\n     Running `target/debug/dockerfile Dockerfile.test`\nglobal arg: ArgInstruction { name: \"foo\", value: None }\nstages:\n  stage #0\n    From(FromInstruction { image: \"foo:443/bar\", index: 0, alias: None })\n  stage #1\n    From(FromInstruction { image: \"localhost/foo\", index: 1, alias: None })\n  stage #2\n    From(FromInstruction { image: \"example.com/foo:bar\", index: 2, alias: None })\n  stage #3\n    From(FromInstruction { image: \"alpine:3.10\", index: 3, alias: None })\n  stage #4\n    From(FromInstruction { image: \"foo/bar\", index: 4, alias: None })\n  stage #5\n    From(FromInstruction { image: \"foo/bar:baz\", index: 5, alias: None })\n  stage #6\n    From(FromInstruction { image: \"hello-world:test\", index: 6, alias: Some(\"foo\") })\n  stage #7\n    From(FromInstruction { image: \"fooasdf\", index: 7, alias: Some(\"bar-baz\") })\n    Run(Exec([\"foo\", \"bar\", \"echo \\\"hello $world\\\"\"]))\n    Run(Shell(\"foo bar baz\"))\n    Arg(ArgInstruction { name: \"image\", value: Some(\"alpine:3.10\") })\n  stage #8\n    From(FromInstruction { image: \"$image\", index: 8, alias: None })\n  stage #9\n    From(FromInstruction { image: \"alpine:3.10\", index: 9, alias: Some(\"foo\") })\n    Run(Exec([\"foo\", \"bar\"]))\n    Run(Shell(\"foo bar baz     qux     qup\"))\n    Copy(CopyInstruction { flags: [CopyFlag { name: \"from\", value: \"foo\" }], sources: [\"/foo/bar\", \"/foo/baz\"], destination: \"/qux/\" })\n    Entrypoint(Shell(\"foo bar baz\"))\n    Entrypoint(Exec([\"foo\", \"bar\", \"baz\"]))\n    Cmd(Shell(\"foo bar\"))\n    Cmd(Exec([\"foo\", \"bar\"]))\n    Copy(CopyInstruction { flags: [], sources: [\"foo\"], destination: \"bar\" })\n    Copy(CopyInstruction { flags: [CopyFlag { name: \"from\", value: \"0\" }], sources: [\"/foo\"], destination: \"/bar\" })\n    Misc(MiscInstruction { instruction: \"other\", arguments: \"foo bar\" })\n    Misc(MiscInstruction { instruction: \"other\", arguments: \"foo bar\" })\n    Env(EnvInstruction([EnvVar { key: \"foo\", value: \"bar baz   qux\" }]))\n    Env(EnvInstruction([EnvVar { key: \"foo\", value: \"bar\" }, EnvVar { key: \"baz\", value: \"qux\" }]))\n    Env(EnvInstruction([EnvVar { key: \"zxcv\", value: \"asdf\" }]))\n    Env(EnvInstruction([EnvVar { key: \"foo\", value: \"bar zxcv\" }, EnvVar { key: \"baz\", value: \"qux\" }, EnvVar { key: \"zxcv\", value: \"asdf\\\"qwerty\" }, EnvVar { key: \"zxcv\", value: \"zxcvzxvb\" }]))\n    Label(LabelInstruction([Label { name: \"foo\", value: \"bar\" }]))\n    Label(LabelInstruction([Label { name: \"foo\", value: \"bar\" }]))\n    Label(LabelInstruction([Label { name: \"foo bar\", value: \"baz qux\" }]))\n    Label(LabelInstruction([Label { name: \"foo  bar\", value: \"baz\\\"  qux\" }]))\n    Misc(MiscInstruction { instruction: \"foo\", arguments: \"bar\" })\n```\n\n### Splicing\n\nSome instruction structs also include character spans for various attributes (or\nthe entire instruction). The included splicing utility can be used to rewrite\nthese spans while preserving other user formatting within the file. For example,\nthis can be used to implement a utility that automatically updates image\nversions, or to provide automated fixes for detected lints.\n\nSee [`examples/splice.rs`](./examples/splice.rs) for an example that rewrites\nimage references.\n\n## Contributing\n\nBug reports, feature requests, and pull requests are welcome! Be sure to read\nthough the [code of conduct] for some pointers to get started.\n\nNote that - as mentioned in the code of conduct - code contributions must\nindicate that you accept the [Developer Certificate of Origin][dco],\nessentially asserting you have the necessary rights to submit the code you're\ncontributing under the project's license (MIT). If you agree, simply pass `-s`\nto `git commit`:\n\n```bash\ngit commit -s [...]\n```\n\n... and Git will automatically append the required `Signed-off-by: ...` to the\nend of your commit message.\n\n[code of conduct]: ./CODE_OF_CONDUCT.md\n[dco]: https://developercertificate.org/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhewlettpackard%2Fdockerfile-parser-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhewlettpackard%2Fdockerfile-parser-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhewlettpackard%2Fdockerfile-parser-rs/lists"}