boot

:boot-clj: https://boot-clj.github.io/ — build tooling for Clojure. Dev chat in #boot-dev
flyboarder 2019-01-13T00:43:52.106300Z

oooo micha thats a good idea, we should include a lein->boot task by default

micha 2019-01-13T00:44:36.106800Z

i think leiningen exposes a lot of that as a library

micha 2019-01-13T00:44:52.107200Z

i seem to recall making something like that a long time ago

flyboarder 2019-01-13T00:45:10.107900Z

i’ll look into it, seems like it would be fairly simple to slurp it up either way

micha 2019-01-13T00:45:11.108Z

like before boot had the minimal set of tasks you need, we used it as a crutch

micha 2019-01-13T00:45:34.108400Z

yeah i think there are lots of ways you can specify dependencies in leiningen

micha 2019-01-13T00:45:46.108700Z

like various profiles and whatnot

micha 2019-01-13T00:46:07.109200Z

i don't think there is a simple single place in the project.clj to look to find dependencies

micha 2019-01-13T00:46:17.109500Z

there are dev dependencies, test dependencies, etc

flyboarder 2019-01-13T00:46:51.110100Z

ok, then the task would either need to replicate some of the lein config or utilize lein to parse the project file

flyboarder 2019-01-13T00:47:31.111Z

that seems rather doable, the boot-shadow task works the same way, we use shadow-cljs as a library

micha 2019-01-13T00:47:32.111100Z

right, i'm pretty sure i recall loading the leiningen namespaces and using those

flyboarder 2019-01-13T00:49:55.111800Z

a few other items on my radar are the dependency loading in general, i’d like to provide options for people who also use tools/deps.edn

flyboarder 2019-01-13T00:50:18.112500Z

the next version of the boot-shadow task will exclusively pull deps from the shadow-cljs.edn file

micha 2019-01-13T00:50:35.112900Z

yep, the boot cp stuff should be pretty good start for tools.deps integration

micha 2019-01-13T00:50:55.113300Z

tools.deps enforces "pedantic mode" or whatever they call it

flyboarder 2019-01-13T00:52:51.113600Z

yeah the nice thing with pods is that we can mix and match

flyboarder 2019-01-13T00:53:42.114300Z

like the shadow task only pulls deps into the pod it uses for compiling, it leaves all the runtime deps to npm

micha 2019-01-13T00:55:40.115200Z

right on

micha 2019-01-13T00:55:45.115500Z

that's perfect

micha 2019-01-13T00:57:45.115800Z

man i'm having some docker troubles

micha 2019-01-13T00:57:50.116Z

do you know about docker?

micha 2019-01-13T00:58:30.116300Z

i guess this isn't the docker channel 🙂

2019-01-13T01:31:51.118Z

What is the process for creating a custom clean task deletes all files in a folder except for .git?

micha 2019-01-13T01:33:27.118900Z

boot isn't really designed for that kind of task, it's designed to leverage immutability in builds

micha 2019-01-13T01:33:49.119400Z

so managing a mutable tree of files is not really someting you probably want to use boot for

micha 2019-01-13T01:34:43.120200Z

in general, boot won't alter any of your files at all

2019-01-13T01:35:01.120700Z

Oh, the use case is when I run build it outputs to the target/public directory and cleans it. But now I want to make the public/target a submodule to a github pages repo so cleaning is fine, I just don’t want it to delete the .git folder if possible.

micha 2019-01-13T01:35:13.121Z

boot tasks only create or modify boot-managed files in the fileset

micha 2019-01-13T01:35:18.121200Z

and those are all immutable

micha 2019-01-13T01:35:56.121700Z

the only place where boot intersects with your project files is when it writes to the target dir

micha 2019-01-13T01:36:11.122100Z

and that is considered write-only as far as boot tasks are concerned

micha 2019-01-13T01:36:28.122500Z

you don't want a task to read from the files in there

micha 2019-01-13T01:37:19.123300Z

you can look at the target task, i bet it would be easy to copy and paste that with a slight modification to do what you need

2019-01-13T01:37:41.123700Z

Ah ok, that’s what I’ve been looking through currently but was curious if that was the best way.

micha 2019-01-13T01:38:07.124100Z

you could just add a --blacklist option perhaps

micha 2019-01-13T01:38:12.124300Z

to the target task

micha 2019-01-13T01:38:23.124600Z

and have it just ignore files that match a regex or something like that

micha 2019-01-13T01:38:30.124800Z

like while it's cleaning

micha 2019-01-13T01:39:19.125200Z

there is also the -C --no-clean option

micha 2019-01-13T01:39:27.125400Z

in the existing target task

micha 2019-01-13T01:39:53.126300Z

you kind of want a more granular no-clean i guess

2019-01-13T01:39:57.126400Z

Yeah, I saw the no clean but cleaning is still a good idea. The blacklist option sounds like what I’m after.

micha 2019-01-13T01:40:35.127Z

👍 Should Be Easy ™️

micha 2019-01-13T01:40:36.127200Z

lol

flyboarder 2019-01-13T01:54:22.127700Z

@micha I do know docker!

micha 2019-01-13T01:55:08.128400Z

i'm mapping in /var/run/docker.sock in my container so i can run another container inception style

micha 2019-01-13T01:55:19.128700Z

that works, i can docker in docker that way

micha 2019-01-13T01:55:46.129300Z

but when i map volumes it looks like i can't map a volume from level1 docker into the level2 docker

micha 2019-01-13T01:55:55.129600Z

i need to map the host directory

micha 2019-01-13T01:56:08.130Z

which makes sense, but it would be great if there was a way around that

flyboarder 2019-01-13T01:56:42.130500Z

hm, I know there are volume mapping issues with docker-in-docker

micha 2019-01-13T01:57:15.131500Z

this isn't technically docker in docker, i'm just making /var/run/docker.sock available in the level1 container

micha 2019-01-13T01:57:23.131800Z

so it can basically call out to the host docker server

micha 2019-01-13T01:57:35.132100Z

i don't run a docker server in the container

micha 2019-01-13T01:58:37.132600Z

ah yes, this SO question is exactly what i'm looking for

flyboarder 2019-01-13T01:59:08.133100Z

yeah it’s not technically docker-in-docker, but I think the symlink might work for you

micha 2019-01-13T01:59:31.133300Z

interesting

micha 2019-01-13T01:59:48.133700Z

my workaround was to just have the paths be the same in docker as on the host

micha 2019-01-13T02:01:46.135600Z

haha that's an answer there already i see

flyboarder 2019-01-13T02:01:53.135900Z

yeah, I am always weary of doing stuff between host/docker, I generally opt for either in docker or out of docker

micha 2019-01-13T02:01:55.136Z

zero upvotes tho

micha 2019-01-13T02:02:20.136400Z

yeah my situation is i have some automation around deployment, cloudformation, and so on

micha 2019-01-13T02:02:48.137300Z

so for managing the infrastructure stuff i like having a docker container with the right versions of everythying, like npm for aws lambda functions, etc

flyboarder 2019-01-13T02:02:56.137800Z

yeah I like the solution you have tho, it makes much more sense instead of a random symlink

micha 2019-01-13T02:03:03.138Z

but i also have submodules for the various services, clojure services and whatnot

micha 2019-01-13T02:03:17.138300Z

and those all have docker containers to build them

flyboarder 2019-01-13T02:03:37.138900Z

omg, so much dockerception

micha 2019-01-13T02:03:38.139Z

so i need to run the build docker container while i'm in the infrastructure container

micha 2019-01-13T02:03:43.139200Z

haha yeah

micha 2019-01-13T02:04:13.140300Z

but it does achieve the goal of not maintaining a "how to prepare your system to build this service" for every service and every OS

flyboarder 2019-01-13T02:04:16.140500Z

If only there was a build tool in clojure you could wire this up with 🙊

micha 2019-01-13T02:04:25.140700Z

it's like just get docker and run the build container

flyboarder 2019-01-13T02:05:13.141200Z

I like this, we use a “boot is the environment” thing so it’s our only hard dependency

micha 2019-01-13T02:05:38.141800Z

haha one of the best reasons to use docker is because you can then write bash scripts without needing to work around OSX braindead bash and coreutils

micha 2019-01-13T02:06:18.141900Z

what about like nodejs dependencies and so on?

micha 2019-01-13T02:06:52.142100Z

like for lambda functions on aws i need a specific version of npm

flyboarder 2019-01-13T02:12:09.143200Z

yeah, thats why I want to get boot running as a native image, so I can just Lisp all the things™️

2019-01-14T09:06:52.160900Z

I believe there could be some synergy between the projects

flyboarder 2019-01-14T15:42:52.162900Z

Awesome! Once I start work on splitting the pods into their own library maybe you can help me test it out

2019-01-14T17:04:48.166800Z

yes, cool

flyboarder 2019-01-13T02:12:22.143500Z

without the performance hit of jvm

flyboarder 2019-01-13T02:13:14.144400Z

it works but it’s highly alpha, Im going to try and get my containers moved over to the native-image and see what kind of performance issue arise

flyboarder 2019-01-13T02:14:20.144500Z

I have never needed anything but the latest version

micha 2019-01-13T02:16:07.144700Z

we use a few different versions, heh

flyboarder 2019-01-13T02:16:18.144900Z

# Node Build
FROM node:alpine AS node

# App Workdir
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# Node Dependencies
COPY ./package.json /usr/src/app
RUN npm install

# Boot Build
FROM <http://cannabit.azurecr.io/cannabit-common:latest|cannabit.azurecr.io/cannabit-common:latest> AS boot

# Boot ENV
ENV BOOT_JVM_OPTIONS=-Xmx2g

# Boot Cache Dependencies
RUN boot repl -e '(System/exit 0)'

# App Workdir
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# App Files
COPY --from=node /usr/src/app .
COPY . /usr/src/app

# App Build
RUN boot build

# Node Runtime
FROM node:alpine AS app

# App Workdir
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

# App Files
COPY --from=boot /usr/src/app/target .

CMD ["node", "nodejs"]

EXPOSE 8080

flyboarder 2019-01-13T02:16:28.145100Z

This is the build we copy-paste everywhere

flyboarder 2019-01-13T02:18:03.146Z

so first we prep and cache as much as we can, then we download all the npm deps, then build with boot, and finally move the app to a fresh node image

micha 2019-01-13T02:18:16.146600Z

do you think graal could be used to build a program that uses for example aws sdk?

flyboarder 2019-01-13T02:19:22.147200Z

hm, I think I saw something about that, but the thing about graal is that it’s closed world, so you need everything at build time

flyboarder 2019-01-13T02:19:31.147500Z

I would imagine the aws sdk is loaded on demand

flyboarder 2019-01-13T02:19:35.147800Z

since it’s so huge

micha 2019-01-13T02:19:41.148Z

you feed it an uberjar i guess?

flyboarder 2019-01-13T02:19:59.148300Z

yeah that might work

flyboarder 2019-01-13T02:20:18.148800Z

easiest way to find out is use the graal docker image and try building your app

micha 2019-01-13T02:20:48.149500Z

i have PTSD from the cljs --advanced optimizations days

micha 2019-01-13T02:20:56.149700Z

i may get triggered

micha 2019-01-13T02:20:58.149900Z

lol

flyboarder 2019-01-13T02:22:42.150100Z

bahahaha

flyboarder 2019-01-13T02:23:31.150800Z

if it doesnt compile then it’s not worth investigating, with boot it compiled fine and I only had to sort out dynamic loading issues

flyboarder 2019-01-13T02:23:54.151100Z

but it seems most projects get stopped at the compile step

flyboarder 2019-01-13T02:24:00.151300Z

and never get to runtime issues 😛

flyboarder 2019-01-13T02:24:31.151600Z

also graal isnt even v1 yet

flyboarder 2019-01-13T02:24:43.152100Z

so I dont plan on releasing the boot version until that happens

micha 2019-01-13T02:24:52.152400Z

i am astounded that you were able to get all the crazy classloadering to work in graal

flyboarder 2019-01-13T02:25:13.152800Z

well it’s fairly simple, you delay all the dynamic stuff to the spawned jvm

flyboarder 2019-01-13T02:25:21.153Z

then it’s business as usual

micha 2019-01-13T02:25:43.153400Z

ahh i see

flyboarder 2019-01-13T02:25:46.153600Z

really we just shift all the static stuff to graal and compile that to native

flyboarder 2019-01-13T02:25:53.153800Z

so it’s really fast

flyboarder 2019-01-13T02:26:24.154200Z

but we do drop 1 level of classloader shims which is nice

micha 2019-01-13T02:27:15.154400Z

that is sweet

flyboarder 2019-01-13T02:54:59.155100Z

nice!

flyboarder 2019-01-13T03:14:00.155900Z

If anyone else is interested in the experimental work on boot:

flyboarder 2019-01-13T03:14:01.156100Z

https://github.com/boot-clj/boot-native

2👏
micha 2019-01-13T03:16:07.156400Z

awesome

martinklepsch 2019-01-13T19:00:13.158100Z

@flyboarder huge kudos for taking over 🙌 Consider applying for the next ClojuristsTogether batch, I think boot would be a great candidate and there's definitely some stuff to do 🙂

1
flyboarder 2019-01-13T21:53:58.158900Z

@martinklepsch I have put my hat in for that! Any funding would help go along way!

1🔥1🎉