{"id":15020018,"url":"https://github.com/docker/babashka-pod-docker","last_synced_at":"2025-10-19T16:32:28.642Z","repository":{"id":167011815,"uuid":"599436857","full_name":"docker/babashka-pod-docker","owner":"docker","description":null,"archived":false,"fork":false,"pushed_at":"2024-12-11T23:44:35.000Z","size":290,"stargazers_count":21,"open_issues_count":4,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-01-30T01:12:40.326Z","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/docker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"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":"2023-02-09T06:04:19.000Z","updated_at":"2025-01-09T14:44:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"6e9e05cf-87d2-46e9-83de-daa448d1d9ee","html_url":"https://github.com/docker/babashka-pod-docker","commit_stats":{"total_commits":45,"total_committers":8,"mean_commits":5.625,"dds":0.6444444444444444,"last_synced_commit":"645ee7fa7b8c659658dbaef7b813b2c8e89f7f3a"},"previous_names":["docker/babashka-pod-docker"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docker%2Fbabashka-pod-docker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docker%2Fbabashka-pod-docker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docker%2Fbabashka-pod-docker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/docker%2Fbabashka-pod-docker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/docker","download_url":"https://codeload.github.com/docker/babashka-pod-docker/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237172166,"owners_count":19266626,"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-09-24T19:54:28.313Z","updated_at":"2025-10-19T16:32:28.263Z","avatar_url":"https://github.com/docker.png","language":"Go","readme":"## Background\n\nThis is a [babashka pod](https://github.com/babashka/pods) that binds some golang functions into a clojure namespace.  Using this pod, clojure programs can parse dockerfiles and docker images names using the \"official\" docker golang libraries.\n\n* [`github.com/docker/distribution/reference`](https://github.com/distribution/distribution/blob/main/reference/reference.go) (for image name parsing)\n* [`github.com/moby/buildkit/frontend/dockerfile/parser`](https://github.com/moby/buildkit/blob/master/frontend/dockerfile/parser/parser.go) (for generating a Dockerfile AST).\n\n## Usage\n\n```clojure\n(require '[babashka.pods :as pods])\n(pods/load-pod 'docker/tools \"0.1.0\")\n; OR use a locally built pod binary\n#_(pods/load-pod \"./babashka-pod-docker\")\n\n;; load-pod will create this namespace with two vars\n(require '[docker.tools :as docker])\n\n;; parse image names using github.com/docker/distribution\n;; turns golang structs into clojure maps\n(docker/parse-image-name \"gcr.io/whatever:tag\")\n;; automatically turns golang errors into Exceptions\n(try\n  (docker/parse-image-name \"gcr.io/whatever/:tag\")\n  (catch Exception e\n    ;; invalid reference format\n    (println (.getMessage e))))\n\n;; parse dockerfiles using github.com/moby/buildkit\n;; returns the Result struct transformed to a clojure map\n(docker/parse-dockerfile \"FROM \\\\\\n    gcr.io/whatever:tag\\nCMD [\\\"run\\\"]\")\n```\n\nLoading `'docker/docker-tools` from the pod registry will download the binary into `${user.home}/.babashka/pods/registry` (the `$BABASHKA_PODS_DIR` environment variable will be used if it exists).\n\n## Building Locally\n\nTo build the golang `parser` binary locally, run `go build`.\n\n```bash\ngo build -o babashka-pod-docker\n```\n\n## Releasing\n\nAll pushes to main will update the 0.1.0 release. This is becaus maintaining the pod version in the repository directory and in the pod registry is tricky.\n\nWe hope to automate all of that in the future.\n\n## Namespace generation\n\nThe `pods/load-pod` call is convenient for a repl-session, or a script, but what if you are `aot` compiling, or building a native binary.  In the example above, the namespaces emitted by `pods/load-pod` are not available until runtime.\n\nHere is an example of bindings that will resolve at compile-time and go through the same dispatch.\n\n```clj\n; require the babashka.pods in a namespace\n(require '[babashka.pods.impl :as impl])\n\n; call at runtime to initialize pod system\n(defn load-pod\n  ([pod-spec] (load-pod pod-spec nil))\n  ([pod-spec version opts] (load-pod pod-spec (assoc opts :version version)))\n  ([pod-spec opts]\n   (let [opts (if (string? opts)\n                {:version opts}\n                opts)\n         pod (impl/load-pod\n              pod-spec\n              (merge {:remove-ns remove-ns\n                      :resolve (fn [sym]\n                                 (or (resolve sym)\n                                     (intern\n                                      (create-ns (symbol (namespace sym)))\n                                      (symbol (name sym)))))}\n                     opts))]\n     (future (impl/processor pod))\n     {:pod/id (:pod-id pod)})))\n\n;; statically define dispatch functions - this is synchronous\n(defn parse [s]\n  (impl/invoke-public \"docker.tools\" \"docker.tools/parse-dockerfile\" [s] {}))\n\n;; async example\n(defn generate-sbom [s]\n  (impl/invoke-public \"docker.tools\" \"docker.tools/generate-sbom\"\n    [s cb]\n    {:handlers {:done (fn [])\n                :success cb\n                :error (fn [err]}})))\n```\n\n```\n(pods/load-pod \"/bin/babashka-pod-docker\")\n```\n\nThis method of dispatch does not require any dynamic namespace generation.\n\n## Contributing\n\nYou can find information about contributing to this project in the CONTRIBUTING.md\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdocker%2Fbabashka-pod-docker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdocker%2Fbabashka-pod-docker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdocker%2Fbabashka-pod-docker/lists"}