Fork me on GitHub
#babashka
<
2021-09-07
>
denik00:09:01

is it possible to use babashka with a bb.edn file in a docker container?

denik00:09:49

getting ns errors

----- Error --------------------------------------------------------------------
Type:     java.lang.Exception
Message:  Could not find namespace: <....>
Location: <expr>:1:10

denik00:09:04

same command outside of docker works fine

Darin Douglass01:09:30

Yes, our CI pipeline, which runs in a docker image, uses bb tasks

Darin Douglass01:09:05

What is the command you're trying to run?

denik01:09:20

simply trying to run main

denik01:09:45

bb -m my.ns

denik01:09:11

this works outside of docker

denik01:09:36

this dockerfile built and run however fails

FROM babashka/babashka:latest

WORKDIR app
COPY . app

CMD bb -m my.ns

Bob B02:09:55

I built this Dockerfile and got two levels of app, so I believe that workdir basically changed the directory to app, and then the copy command did the copy into an app subfolder, so I'd say be sure the directory structure in the container is as you expect - for example, changing the copy command to copy . . made this example work in my context

Darin Douglass11:09:07

Thanks for the info and sorry for the late reply. Bob’s right: the COPY line is the problem, fix that and you’re golden

denik15:09:46

sadly it’s still not working

denik15:09:13

Message:  Could not find namespace: medley.core.
Location: /app/src/zoomership.clj:2:5

----- Context ------------------------------------------------------------------
1: (ns zoomership
2:     (:require
       ^--- Could not find namespace: medley.core.

denik15:09:20

deps

{:paths          ["." "src"]
 :min-bb-version "0.6.0"
 :deps           {lambdaisland/uri {:mvn/version "1.4.74"}
                  medley/medley    {:mvn/version "1.3.0"}}}

borkdude15:09:46

is this a bb.edn file? I think you will have most luck to provide a complete repro repository which people can run

👍 2
denik15:09:16

yes I’m working on replicating it into a repo rn

borkdude16:09:18

The error you're seeing there is because deps are downloaded using java

borkdude16:09:42

you can avoid this by building an uberjar outside of the docker image, or downloading your deps to a separate .m2 folder and copying that into the docker container

borkdude16:09:46

with bb uberjar

borkdude16:09:22

I'll make a proposal as a PR

borkdude17:09:40

I’ll follow up with a better approach

borkdude20:09:52

@U097654L8 I think the above approach can also work for clojure deps: just build an uberjar and then set the classpath for Clojure to that uberjar using -Scp

borkdude20:09:08

This will guarantee to not use the internet

🙏 2