Is there a way to compile bb scripts to native code ? I just wrote this script: https://repo.prod.meissa.de/meissa/c4k-website/pulls/14/files#diff-c324658b2f31051108a426dac8fb2ebe2fb14073 It needs bb-static & java to be installed in the image. Is there a way to get rid of java ?
Does this help? https://github.com/babashka/babashka/wiki/Self-contained-executable
bb uberjar foo.jar
leaves some questions:
1. can I create a uberjar from a script (http://package.bb) in my example ?
2. but uberjar just contains all libs in a single jar. This means I will further need the java runtime. Correct?3. is there a simple way to convert a bb-build uberjar to a native compiled binary (there are always tricky details in graal builds - assume this is true also for bb) ?
@jerger_at_dda 1. yes. you need to add a -main function to your script and you can also add this:
#!/usr/bin/env bb
;; Various functions defined here
(defn -main [& args]
;; Implementation of main
)
(when (= *file* (System/getProperty "babashka.file"))
(apply -main *command-line-args*))
so you can still invoke the file directly.
2. no java runtime needed
3. yes, using the documentation in the wiki above, did you read it? no graalvm neededYes, read it but my eyes missed the "binary" word as there was "uberjar" nearby ... sorry ... and thx for the hint :-)
it looks cool but what is it?
This image we use for downloading & unzip our website as package from our forgejo repo in an cron job. The small image consist of your bb alpine image + bb script-uberjars needed, The large one contains debian-slim, jre-headless, clojure, m2, bb and the same bb scripts. Probably this could be optimized down to 300-400M ...