{"id":27599657,"url":"https://github.com/vehvis/lein-jib-build","last_synced_at":"2025-04-22T15:40:46.544Z","repository":{"id":62435056,"uuid":"170515918","full_name":"vehvis/lein-jib-build","owner":"vehvis","description":"Build docker containers with Leiningen, without Docker.","archived":false,"fork":false,"pushed_at":"2020-05-11T19:39:01.000Z","size":38,"stargazers_count":27,"open_issues_count":1,"forks_count":3,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-16T20:17:03.843Z","etag":null,"topics":["clojure","docker","leiningen-plugin"],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vehvis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2019-02-13T13:50:52.000Z","updated_at":"2022-11-29T19:17:33.000Z","dependencies_parsed_at":"2022-11-01T21:15:49.206Z","dependency_job_id":null,"html_url":"https://github.com/vehvis/lein-jib-build","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vehvis%2Flein-jib-build","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vehvis%2Flein-jib-build/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vehvis%2Flein-jib-build/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vehvis%2Flein-jib-build/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vehvis","download_url":"https://codeload.github.com/vehvis/lein-jib-build/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250269763,"owners_count":21402931,"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":["clojure","docker","leiningen-plugin"],"created_at":"2025-04-22T15:40:41.333Z","updated_at":"2025-04-22T15:40:46.512Z","avatar_url":"https://github.com/vehvis.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lein-jib-build\n\nBuild docker containers with Leiningen, no docker installation needed. Uses Google's [Jib](https://github.com/GoogleContainerTools/jib) toolkit.\n\n\u003e**Note!** This is alpha quality code and has not been thoroughly tested. Use at your own discretion (and create a PR if you improve something)\n\n## Requirements and caveats\n\nClojure 1.10.0 or later is needed. Leiningen 2.9.0 or later is needed. This will probably work with Java 8 but\nI've only tested with Java 11.\n\nDocker is required only if you want to use images from or deploy images to your local docker repository. Remote registries\nand tarfiles work without Docker.\n\n**Your project must emit an uberjar** or something closely like it for this plugin to be useful in its current state.\n\n## Usage\n\nThe plugin is available on clojars: https://clojars.org/vaik.io/lein-jib-build\n\nConfigure your project.clj as follows:\n\n```clojure\n  :plugins [[vaik.io/lein-jib-build \"0.2.0\"]]\n  :jib-build/build-config {:base-image {:type :registry\n                                        :image-name \"gcr.io/distroless/java\"}\n                           :target-image {:type :docker\n                                          :image-name \"helloworld\"}}\n\n```\n\nBuild the image and deploy it to the local docker repo:\n\n    $ lein do uberjar, jib-build\n\nNow you can run it:\n\n    $ docker run helloworld\n    Hello, world!\n\nThere's also an [example project](https://github.com/vehvis/lein-jib-build/tree/master/lein-jib-build-test) you can take a look at.\n\n\n## Configuration options\n\nThe `:jib-build/build-config` map has the following required options:\n* `:target-image {...}` - what to do with the built image, also see below\n\nThe following are optional:\n* `:base-image {...}` - base Docker image to build upon, see below for details. Defaults to `gcr.io/distroless/java`.\n* `:entrypoint [...]` - a vector of strings to use as the container's ENTRYPOINT value, defaults to `[\"java\" \"-jar\"]`\n* `:arguments \"...\"` - a string to give to the entrypoint as arguments, defaults to the name of the project's uberjar.\n\n#### Referring to images\n\nThese options are usable with both `base-image` and `target-image`.\n\n```clojure\n;; Deploy to (or build upon an image from) your local docker daemon (requires dockerd to be running)\n:target-image {:type :docker\n               :image-name \"helloworld\"}\n```\n```clojure\n;; Deploy as (or build upon) a tar archive\n:target-image {:type :tar\n               :image-name \"target/helloworld.tar\"}\n```\n```clojure\n;; Deploy to (or build upon an image from) a Docker registry with optional username/password authentication \n;; Please mind your security!\n:target-image {:type :registry\n               :image-name \"repository.mordor.me/sauron/helloworld\"\n               :username \"sauron\"       ;; optional\n               :password \"VERYSECRET\"   ;; optional\n               }\n```\n\n#### Pull from or push to AWS ECR, with authentication\n\nIf you're using AWS ECR there's direct support for more sophisticated authentication.\n\nDeploy to ECR with assume-role (uses the standard AWS credential chain):\n\n```clojure\n:target-image {:type :registry\n               :image-name \"123456789.dkr.ecr.mordor-east-1.amazonaws.com/helloworld\"\n               :authorizer {:fn leiningen.aws-ecr-auth/ecr-auth\n                            :args {:type :assume-role\n                                   :role-arn \"arn:aws:iam::123456789:role/nazgul\"}}}\n```\n\nDeploy to ECR using a specific profile:\n\n```clojure\n:target-image {:type :registry\n               :image-name \"123456789.dkr.ecr.mordor-east-1.amazonaws.com/helloworld\"\n               :authorizer {:fn leiningen.aws-ecr-auth/ecr-auth\n                            :args {:type :profile\n                                   :profile-name \"nazgul\"}}}\n```\n\nUsing environment variables:\n* `AWS_ACCESS_KEY_ID`      (required)      \n* `AWS_SECRET_ACCESS_KEY`  (required)\n* `AWS_SESSION_TOKEN`      (optional)\n```clojure\n:target-image {:type :registry\n               :image-name \"123456789.dkr.ecr.mordor-east-1.amazonaws.com/helloworld\"\n               :authorizer {:fn leiningen.aws-ecr-auth/ecr-auth\n                            :args {:type :environment}}}\n```\n\nWith an access key:\n```clojure\n:target-image {:type :registry\n               :image-name \"123456789.dkr.ecr.mordor-east-1.amazonaws.com/helloworld\"\n               :authorizer {:fn leiningen.aws-ecr-auth/ecr-auth\n                            :args {:type :access-key\n                                   :access-key-id \"AK1231232414\"\n                                   :secret-access-key \"111111111111111\"}}}\n```\n\nWith JVM system properties:\n* `aws.accessKeyId`  (required)\n* `aws.secretKey`    (required)\n\n```clojure\n:target-image {:type registry\n               :image-name \"123456789.dkr.ecr.mordor-east-1.amazonaws.com/helloworld\"\n               :authorizer {:fn leiningen.aws-ecr-auth/ecr-auth\n                            :args {:type :system-properties}}}\n```\n\n#### Using a custom registry authorizer\n\nNothing prevents you from making a custom authorizer just like the ECR thing above.\nCreate a function in a namespace accessible to leiningen with a single argument, and \nhave it return a username/password map:\n\n```clojure\n(defn custom-authorizer [config] \n   {:username (:username config)\n    :password (apply str (reverse (:encrypted-password config))})\n```\n\nThe function gets passed the `args` map from your `project.clj`:\n\n```clojure\n:target-image {:type :registry\n               :image-name \"123456789.dkr.ecr.mordor-east-1.amazonaws.com/helloworld\"\n               :authorizer {:fn my-namespace/my-custom-authorizer\n                            :args {:username \"Sauron\" :encrypted-password \"TERCESYREV\"}}}\n```\n\n## Building (\u0026 other irritations)\n\nSo that things would not be too easy, Leiningen includes some libraries that are a bit long in the tooth. \nAnd when creating plugins, those libraries override everything you bring with you.\n\nThe main culprit in this case is Guava, a current version of which is required by the `jib-core` library used \nby this plugin. Leiningen however provides an old version, so we need to shadow the Guava library inside jib-core\nfor it to function. \n\nI have placed a forked version of `jib` as a Git submodule, which contains the required shadowing configuration.\n\nThe included build.sh script does everything that's needed:\n\n```shell script\n$ ./build.sh\n--- Checking that we have the required submodule\n--- Build the customised jib-core\nBUILD SUCCESSFUL in 2s\n4 actionable tasks: 2 executed, 2 up-to-date\n'jib/jib-core/build/libs/jib-core-0.12.1-SNAPSHOT-GUAVASHADOW.jar' -\u003e 'lib/jib-core-0.12.1-SNAPSHOT-GUAVASHADOW.jar'\n--- Now build the plugin\nCreated /..../lein-jib-build/target/lein-jib-build-0.2.0.jar\nWrote /..../lein-jib-build/pom.xml\nInstalled jar and pom into local repo.\n```\n\nAnother similar thing is that Leiningen includes an old version of `clojure.data.xml`, which is slightly incompatible\nwith the `cognitect/aws-api` library used for ECR authentication. There's an ugly `with-redefs` somewhere because \nof that.\n\n## License\n\nCopyright 2019 Ville Vehviläinen\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\n    http://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvehvis%2Flein-jib-build","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvehvis%2Flein-jib-build","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvehvis%2Flein-jib-build/lists"}