Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add entry-point option to Jibbit config #24

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/jibbit/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
target-image))

;; assumes aot-ed jar is in root of WORKDIR
(defn entry-point
(defn default-entry-point
[{:keys [basis aot jar-name main working-dir]}]
(into ["java" "-Dclojure.main.report=stderr" "-Dfile.encoding=UTF-8"]
(concat
Expand Down Expand Up @@ -214,7 +214,7 @@
else copy source/resource paths too
- try to set a non-root user
- add org.opencontainer LABEL image metadata from current HEAD commit"
[{:keys [git-url base-image target-image working-dir tags debug allow-insecure-registries env-vars exposed-ports]
[{:keys [git-url base-image target-image working-dir tags debug allow-insecure-registries env-vars exposed-ports entry-point]
:or {base-image {:image-name "gcr.io/distroless/java"
:type :registry}
target-image {:type :tar}
Expand Down Expand Up @@ -243,7 +243,7 @@
(assoc :working-dir working-dir)
(merge (user-group-ownership c)))))
(set-user! (assoc c :base-image base-image))
(.setEntrypoint (entry-point c)))
(.setEntrypoint ((or (util/load-var entry-point) default-entry-point) c)))
(-> (cond-> target-image
(first tags) (assoc :tag (first tags))
(:image-name target-image) (update :image-name util/env-subst #(.get (System/getenv) %)))
Expand Down Expand Up @@ -328,14 +328,14 @@

(defn layers
[params]
(let [{:keys [basis working-dir jar-file jar-name] :as jib-config} (create-jib-config params)]
(let [{:keys [basis working-dir jar-file jar-name entry-point] :as jib-config} (create-jib-config params)]
(report/layer-report
jib-config
(libs basis working-dir)
(entry-point jib-config)
(manifest-class-path basis working-dir)
(get-path jar-file)
(docker-path working-dir jar-name))))
jib-config
(libs basis working-dir)
((or (util/load-var entry-point) default-entry-point) jib-config)
(manifest-class-path basis working-dir)
(get-path jar-file)
(docker-path working-dir jar-name))))

(comment
(layers {:project-dir "/Users/slim/vonwig/clj-web" :config (edn/read-string (slurp "/Users/slim/vonwig/clj-web/jib-1.edn"))})
Expand Down
8 changes: 7 additions & 1 deletion src/jibbit/util.clj
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,10 @@
(when-not
(s/valid? ::parsed-docker-port parsed)
(throw (ex-info (s/explain-str ::parsed-docker-port parsed) {:pp pp})))
parsed))
parsed))

(defn load-var
[entry-point]
(when-let [sym (some-> entry-point symbol)]
(some-> sym namespace symbol require)
(resolve sym)))