Skip to content

Commit c1e93c0

Browse files
Slim/graph (#29)
* refactor to simple graph loop * Run in jvm
1 parent ed6e552 commit c1e93c0

26 files changed

+2703
-482
lines changed

.envrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
use flake

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@
1010
/functions/tree-sitter/main
1111
/functions/tree-sitter-clj/target/
1212
/functions/tree-sitter-clj/.cpcache/
13+
/.cpcache/

Dockerfile

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,40 @@
1-
FROM babashka/babashka:latest@sha256:4bc4beea38406782845ae8effaa9bd2f45345d46a4290ea4c96037970a0ca430 AS bb
2-
3-
FROM bb AS base
4-
5-
RUN <<EOF
6-
apt-get update
7-
apt-get install -y git
1+
# syntax = docker/dockerfile:1.4
2+
FROM nixos/nix:2.21.1@sha256:3f6c77ee4d2c82e472e64e6cd7087241dc391421a0b42c22e6849c586d5398d9 AS builder
3+
4+
WORKDIR /tmp/build
5+
RUN mkdir /tmp/nix-store-closure
6+
7+
# ignore SC2046 because the output of nix-store -qR will never have spaces - this is safe here
8+
# hadolint ignore=SC2046
9+
RUN --mount=type=cache,target=/nix,from=nixos/nix:2.21.1,source=/nix \
10+
--mount=type=cache,target=/root/.cache \
11+
--mount=type=bind,target=/tmp/build \
12+
<<EOF
13+
nix \
14+
--extra-experimental-features "nix-command flakes" \
15+
--option filter-syscalls false \
16+
--extra-trusted-substituters "https://cache.iog.io" \
17+
--extra-trusted-public-keys "hydra.iohk.io:f/Ea+s+dFdN+3Y/G+FDgSq+a5NEWhJGzdjvKNGv0/EQ=" \
18+
--show-trace \
19+
--log-format raw \
20+
build . --out-link /tmp/output/result
21+
cp -R $(nix-store -qR /tmp/output/result) /tmp/nix-store-closure
822
EOF
923

10-
FROM eclipse-temurin:latest@sha256:ac1545309de7e27001a80d91df2d42865c0bacaec75e016cb4482255d7691187 AS build
11-
12-
WORKDIR /app
13-
14-
COPY --from=bb /usr/local/bin/bb /usr/local/bin/bb
15-
COPY bb.edn bb.edn
16-
COPY ./src ./src
17-
RUN bb uberjar prompts.jar -m prompts
18-
19-
FROM base
24+
FROM scratch
2025

2126
WORKDIR /app
2227

23-
COPY ./extractors/registry.edn ./extractors/registry.edn
24-
COPY ./functions/registry.edn ./functions/registry.edn
28+
COPY --from=builder /tmp/nix-store-closure /nix/store
29+
COPY --from=builder /tmp/output/ /app/
2530

26-
COPY --from=build /app/prompts.jar /app/prompts.jar
31+
# curl needs the /tmp directory to already exist
32+
COPY <<EOF /tmp/.blank
33+
empty
34+
EOF
2735

28-
COPY prompts/docker docker
29-
COPY prompts/lazy_docker lazy_docker
36+
COPY <<EOF /root/.blank
37+
empty
38+
EOF
3039

31-
# Can't be shell form because we need to pass JSON as an arg
32-
ENTRYPOINT [ "bb", "/app/prompts.jar" ]
40+
ENTRYPOINT ["/app/result/bin/entrypoint"]

bb.edn

Lines changed: 0 additions & 5 deletions
This file was deleted.

build.clj

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
(ns build
2+
(:require [clojure.tools.build.api :as b]))
3+
4+
(def build-folder "target")
5+
(def jar-content (str build-folder "/classes"))
6+
7+
(def basis (b/create-basis {:project "deps.edn"
8+
:aliases [:native]}))
9+
(def app-name "chat-sdlc")
10+
(def uber-file-name (format "%s/%s-standalone.jar" build-folder app-name)) ; path for result uber file
11+
12+
(defn clean [_]
13+
(b/delete {:path "target"})
14+
(println (format "Build folder \"%s\" removed" build-folder)))
15+
16+
(defn uber [_]
17+
#_(clean nil)
18+
19+
(b/copy-dir {:src-dirs ["resources"] ; copy resources
20+
:target-dir jar-content})
21+
22+
(b/compile-clj {:basis basis ; compile clojure code
23+
:src-dirs ["src"]
24+
:class-dir jar-content})
25+
26+
(b/uber {:class-dir jar-content ; create uber file
27+
:uber-file uber-file-name
28+
:basis basis
29+
:main 'docker.main}) ; here we specify the entry point for uberjar
30+
31+
(println (format "Uber file created: \"%s\"" uber-file-name)))

0 commit comments

Comments
 (0)