atomisthq / jibbit

Dockerless Clojure Image builds using deps.edn
Eclipse Public License 1.0
111 stars 9 forks source link

Add entry-point option to Jibbit config #24

Open skydread1 opened 6 months ago

skydread1 commented 6 months ago

Closes #23

changes

Example of use case

For example, a project might want to have some env var passed down and a specify the shell like so:

(ns jibbit
  (:require [jibbit.core :as jibbit]))

(defn my-entry-point
  [{:keys [basis main working-dir]}]
  (->> (concat
        ["java ${JAVA_OPTS} -Dclojure.main.report=stderr -Dfile.encoding=UTF-8"]
        (concat
         ["-cp" (jibbit/container-cp basis working-dir) "clojure.main"]
         (if-let [main-opts (-> basis :argmap :main-opts)]
           main-opts
           ["-m" (pr-str main)])))
       (interpose " ")
       (apply str)
       (conj ["/bin/sh" "-c"])))

Then, this implementation can be specified in the jib.edn for instance:

{:main         my.app.core
 :user         "root"
 :group        "root"
 :base-image   {:image-name "openjdk:11-slim-buster"
                :type       :registry}
 :target-image {:image-name "props-reco/test"
                :type       :docker
                :tag "test"}
 :entry-point jibbit/my.entry-point}