msv-lab / modus

A language for building Docker/OCI container images
GNU Affero General Public License v3.0
279 stars 9 forks source link

Buildkit integration #67

Closed maowtm closed 2 years ago

maowtm commented 2 years ago

(query was a(X))

A very basic version supporting only from and run, and currently does not yet do multiple output extraction nor fetch inherited properties. Just wanted to get this out first and see what you think.

Code might be a bit messy since it's 2am now. Will clean up later.

If the frontend (running inside a buildkit-created container) encounters an error it is crazy hard to debug, since buildkit does not print out the stderr of frontend (stdout is used for protocol), and also, for some reason, run containers in its own environment which docker ps can't access.


maowtm commented 2 years ago

By the way, for tests we can actually (instead of actually building the image and testing its properties) just test if the generated build plan is correct. This should be a bit easier then checking image equality somehow, especially when network requests or ignore_cache is involved. We can test the translation from build plan to buildkit separately.

Although I guess we could still have a few true integration tests - just in case.

maowtm commented 2 years ago

TODO: rename ::workdir to ::in_workdir done

maowtm commented 2 years ago

This is now ready to merge. The test failure seems to be related to https://github.com/modus-continens/modus/issues/65 .

maowtm commented 2 years ago
cargo run -- build 'Modusfile' 'all(X)'

output screenshot

thevirtuoso1973 commented 2 years ago

This is now ready to merge. The test failure seems to be related to #65.

If you want to try, it should pass if you re-run it a couple times. Some permutation should work.

maowtm commented 2 years ago

Due to https://github.com/modus-continens/modus/issues/74, when testing this, Modusfile need to be changed in the following way temporarily:Resolved

@@ -23,13 +23,13 @@ build(profile) :-
 frontend_img(profile) :-
   (run_env,
     profile_to_target_folder(profile, target_folder),
-    (build(profile))::copy(f"${target_folder}/buildkit-frontend", "./buildkit-frontend")
+    (build(profile))::copy(f"./${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"${target_folder}/modus", "./modus")
+    (build(profile))::copy(f"./${target_folder}/modus", "./modus")
   )::set_entrypoint("./modus").

 profile_to_target_folder("debug", "target/debug").