Watch
0
0
Fork
You've already forked hyperhive
0

images: slim OCI images of the swarm daemons from nix

This commit is contained in:
atlas 2026-11-19 09:37:41 +01:00 • committed by mara
commit 29ca381114

68
nix/images/default.nix Normal file
View file

@ -0,0 +1,68 @@
# Slim OCI images of the swarm daemons. Imported from ../packages/default.nix
# with the per-bin packages, and from ../checks.nix for `mkServiceImage` alone.
{
pkgs,
lib,
packages ? { },
}:
let
# The conventional nonroot id. An OCI image has no `config.ids` to take it
# from, so it is defined once here: the image's `User`, the smoke check and
# a pod's `securityContext.runAsUser`/`runAsGroup` must all read this.
serviceUser = {
uid = 65532;
gid = 65532;
};
# One daemon per image: the binary, CA roots and the binary's own closure.
# No shell and no init, so the image has no command to exec into and no
# service manager to disagree with the kubelet about restarts.
#
# `buildLayeredImage` writes a `.tar.gz`, which `podman load`, `skopeo` and
# k3s's image directory read. `streamLayeredImage` writes a script instead.
# `tag` stays unset, so it is the content hash and a changed binary is a
# changed reference; `imageName` and `imageTag` are on the result.
mkServiceImage =
{
name,
package,
bin ? name,
extraContents ? [ ],
env ? { },
}:
pkgs.dockerTools.buildLayeredImage {
name = "hyperhive/${name}";
contents = [
package
pkgs.cacert
]
++ extraContents;
config = {
Entrypoint = [ "/bin/${bin}" ];
Env = [
"SSL_CERT_FILE=/etc/ssl/certs/ca-bundle.crt"
]
++ lib.mapAttrsToList (k: v: "${k}=${v}") env;
User = "${toString serviceUser.uid}:${toString serviceUser.gid}";
};
};
daemon =
name:
mkServiceImage {
inherit name;
package = packages.${name};
};
in
{
inherit mkServiceImage serviceUser;
images = lib.genAttrs [
"swarm-controller"
"swarm-nats-auth"
"swarm-logs-auth"
"swarm-metrics-auth"
"swarm-notify-router"
"swarm-ci-metrics"
] daemon;
}