Implement a dockerTools.buildLayeredImage target for obelisk projects#697
Implement a dockerTools.buildLayeredImage target for obelisk projects#697fabianhjr wants to merge 1 commit into
Conversation
9362ccb to
131a593
Compare
131a593 to
37f36e1
Compare
e517de9 to
e73cdcc
Compare
|
Awesome! We'll try to get this in! |
|
Hi @3noch, good to hear. Currently doing some testing with some of the changes made from the original merge request. :3 Though, it will take me some time to really get a feel about this. First time doing anything docker/k8s related. I can say with confidence that buildLayeredImage, nix and obelisk have been really interesting to learn about. Anyways, here are the layers created for the project I am currently working on (https://gitlab.com/LibreCybernetics/LaTiendita/-/tree/1df40b5d8b984e55588b4ada1ec70db336cb40c5): |
|
And it is live :') |
|
Hi @3noch, on some further testing it seems like nix is packaging obelisk projects alongside thunks (like obelisk/obvelisk-oauth) as a single package and that stops some reusability from happening in the layered docker image. I tried reading some of the nix expressions but wouldn't know how to separate them into packages. :C |
|
Obelisk executables are statically linked. Perhaps that's what you're seeing? However, it's uncommon to layer multiple nix produced Docker images. It's more common, I think, to do your layering in nix and then produce a single Docker image at the end. Nix is better at sharing correctly than Docker. |
Yes, however this is for deployment from nix, Docker doesn't build the layers nix does as per documentation:
It would be really neat if for this small project the difference (the project itself) could get to about 50 MB or so. (Though I am not really sure how small or not the resulting single project layer can get) EDIT: That way space usage in Container Registries could be reduced. |
e73cdcc to
c3673cf
Compare
|
If the docker image size is the problem then what we probably need to do is figure out how to minimize our nix closure for obelisk projects. I've looked into this before and I suspect we can make the closure much smaller. That will produce smaller Docker images. |
| )) | ||
| ]; | ||
| Expose = 8000; | ||
| Entrypoint = ["/var/lib/backend/backend"]; |
There was a problem hiding this comment.
We shouldn't have hardcoded this. We'll probably have to move this nix into the mkObelisk module function so that one can get a docker image for obelisk without assuming default configuration.
There was a problem hiding this comment.
Will look into it
There was a problem hiding this comment.
If I understood this correctly then any changes on internalPort should propagete to the docker target. It should now not be hardcoded.
There was a problem hiding this comment.
As per the entrypoint, if I understand this correctly that location is being grabbed from nix and symlinked in line 172
|
I think the closure doesn't need to be smaller. Maybe dynamically building and having thunks be their own nixpkg would allow nix to split them into different docker layers. (However that is a future nice to have) |
c3673cf to
2936836
Compare
| To build with a custom configuration, Obelisk's default configuration can be imported and overriden in a `release.nix` file added to your top-level directory: | ||
|
|
||
| ```nix | ||
| { }: |
There was a problem hiding this comment.
A function from the empty set seems not useful. Is there something I'm missing with this?
There was a problem hiding this comment.
Don't think so, not that I could find from #512
e5f18c3 to
ee5afdd
Compare
ee5afdd to
6c6bf0a
Compare
6c6bf0a to
a7cdad2
Compare
a7cdad2 to
09c951f
Compare
cbf0779 to
1938f13
Compare
1938f13 to
13e94d2
Compare
13e94d2 to
fa13ea6
Compare
fa13ea6 to
9f718bc
Compare
Documentation on this extra target can be found in nix's dockerTools documentation: https://nixos.org/nixpkgs/manual/#sec-pkgs-dockerTools Co-authored-by: Joe Betz <joebetz91@gmail.com> Co-authored-by: Fabián Heredia Montiel <fabianhjr@protonmail.com>
9f718bc to
7c12cc9
Compare
|
@fabianhjr is this still being worked on and wanted? |
|
I haven't used obelisk in a while, it is something I wanted though. Feel free to rebase and reopen a merge request. |



This is a rebase (solving conflicts) and squash of #512
I have:
developbranchhlint .(lint found code you did not write can be left alone)$(nix-build -A selftest --no-out-link)nix-build release.nix -A build.x86_64-linux --no-out-link(orx86_64-darwinon macOS)Changes from #512: