This repository has been archived by the owner on Aug 2, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathModusfile
58 lines (49 loc) · 2.24 KB
/
Modusfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
build_env :-
(from("rust:alpine")::set_workdir("/usr/src/app"),
# musl-dev required for tokio (https://github.com/hound-search/hound/issues/238#issuecomment-336915272),
# protobuf-dev required for buildkit-proto -> tonic-build
# git required for our build.rs
run("apk add --no-cache musl-dev protobuf-dev git"))
::set_env("PROTOC", "/usr/bin/protoc")
::set_env("PROTOC_INCLUDE", "/usr/include/google/protobuf").
run_env :- from("alpine")::set_workdir("/usr/src/app").
cargo_build("debug") :- run(f"cargo build").
cargo_build("release") :- run(f"cargo build --release").
build_deps(profile) :-
copy("modus-lib/Cargo.toml", "modus-lib/"),
copy("modus/Cargo.toml", "modus/"),
copy("Cargo.toml", "."),
copy("Cargo.lock", "."),
copy("rust-toolchain.toml", "."),
run("mkdir modus-lib/src modus/src &&\
echo 'pub struct Nothing;' > modus-lib/src/lib.rs &&\
echo 'fn main () {}' > modus/src/main.rs &&\
echo 'fn main () {}' > modus/src/buildkit_frontend.rs"),
cargo_build(profile).
build(profile) :-
build_env,
build_deps(profile),
copy(".", "."),
# Since cargo use the timestamp of build artifact to determine if it needs to
# rebuild, and the source file copied in will be older than the previous build
# done by build_deps, we touch all the source files to force a re-build.
run("touch modus-lib/src/* modus/src/*"),
cargo_build(profile).
frontend_img(profile) :-
(run_env,
profile_to_target_folder(profile, target_folder),
# Work-around for https://github.com/modus-continens/modus/issues/98
# We need to transpile this to Dockerfile to bootstrap the frontend.
# Normally just saying f"${target_folder}/..." is good enough.
build(profile)::copy(f"/usr/src/app/${target_folder}/buildkit-frontend", "./buildkit-frontend")
)::set_entrypoint(["./buildkit-frontend"]).
modus(profile) :-
(run_env,
profile_to_target_folder(profile, target_folder),
build(profile)::copy(f"/usr/src/app/${target_folder}/modus", "./modus")
)::set_entrypoint(["./modus"]).
profile_to_target_folder("debug", "target/debug").
profile_to_target_folder("release", "target/release").
all("modus", profile) :- modus(profile).
all("frontend", profile) :- frontend_img(profile).
all(X) :- all(X, "debug").