Fork me on GitHub
#babashka
<
2021-09-17
>
Carsten Behring12:09:26

I use the docker pod like this:

(require '[babashka.pods :as pods])
(require '[clojure.java.shell :refer [sh]])
(require '(clojure.java [io :as io]))

(pods/load-pod 'lispyclouds/docker "0.1.1")
(require '[pod.lispyclouds.docker :as docker])

(def images (docker/client {:category :images
                            :conn     {:uri "unix:///var/run/docker.sock"}}))

(shell/sh "tar cf /tmp/context.tar .")

(def is (io/input-stream "/tmp/context.tar"))
(docker/invoke images {:op :ImageBuild
                       :inputStream is
                       :dockerfile "Dockerfile"})
To do a

Carsten Behring12:09:29

But I get a error message which I don't understand, and seem to be related to babashka

clojure.lang.ExceptionInfo: No reader function for tag object
{:type :sci/error, :line 1, :column 1, :message "No reader function for tag object", :sci.impl/callstack #object[clojure.lang.Delay 0x5b73dbd7 {:status :pending, :val nil}], :file "/home/carsten/Dropbox/sources/scicloj-tooling/zero-to-interop.bb", :locals {}}
 at sci.impl.utils$rethrow_with_location_of_node.invokeStatic (utils.cljc:71)
    sci.impl.evaluator$eval.invokeStatic (evaluator.cljc:329)
    sci.impl.interpreter$eval_form.invokeStatic (interpreter.cljc:78)
    sci.core$eval_form.invokeStatic (core.cljc:270)
    babashka.nrepl.impl.server$eval_msg$fn__34566$fn__34567.invoke (server.clj:61)
    babashka.nrepl.impl.server$eval_msg$fn__34566.invoke (server.clj:57)
    babashka.nrepl.impl.server$eval_msg.invokeStatic (server.clj:47)
    babashka.nrepl.impl.server$session_loop.invokeStatic (server.clj:242)
    babashka.nrepl.impl.server$listen$fn__34639.invoke (server.clj:283)
    sci.impl.vars$binding_conveyor_fn$fn__700.invoke (vars.cljc:154)
    clojure.core$binding_conveyor_fn$fn__5773.invoke (core.clj:2034)

borkdude12:09:29

@U7CAHM72M Ah I see. You cannot push the input stream over the wire to the pod function call. Pod functions work via RPC and you can't serialize an inputstream via edn or transit

borkdude12:09:53

Perhaps @rahul080327, the author of this pod, knows a better alternative

borkdude12:09:35

Is it possible to just pass a :file or so?

lispyclouds12:09:56

This unfortunately is a requirement of the docker API and hence the lib that i wrote too. Probably in this case its better to shell out to the docker cli and do the build as i can see the docker daemon locally running

lispyclouds12:09:27

(shell/sh "docker build .")

👍 2
borkdude12:09:29

@rahul080327 you could serialize the :inputstream argument to a byte array though and then make it an inputsteam again on the pod side. This is just work that comes with pod making.

borkdude12:09:41

I've done similar things with the sql pods

borkdude12:09:48

it's using transit which makes this a lot easier

lispyclouds13:09:55

yeah i can think about it sometime soon, probably can use the newer lib for the pod

borkdude13:09:10

the contajners one?

lispyclouds13:09:23

new pod in fact

borkdude21:09:27

This needs to be shared here. Calling native libraries from bb: https://github.com/babashka/babashka/discussions/1011 /cc @suskeyhose @rahul080327

Joshua Suskalo22:09:32

is libffi a graal library?

phronmophobic23:09:19

graalvm has a c ffi, but you can't load and call c libraries dynamically, https://www.graalvm.org/reference-manual/native-image/C-API/

Joshua Suskalo21:09:05

ah, I see. that makes sense.