nix: copy assets in docker, need to finish env

This commit is contained in:
Philippe Loctaux 2023-11-17 22:33:50 +01:00
parent 89e0432b7a
commit 3b9f4792dc

View file

@ -87,10 +87,30 @@
});
# Build crate
ezidam = craneLib.buildPackage (commonArgs // {
ezidamBinary = craneLib.buildPackage (commonArgs // {
cargoArtifacts = ezidamClippy;
});
ezidamAssetTemplate = ./crates/ezidam/templates;
ezidamAssetStatic = ./crates/ezidam/static;
ezidamAssets = [
ezidamAssetTemplate
ezidamAssetStatic
];
ezidam = pkgs.stdenv.mkDerivation {
inherit ezidamBinary ezidamAssets;
name = metadata.pname;
phases = [ "unpackPhase" "installPhase" ];
dontUnpack = true;
installPhase = ''
mkdir -p $out
cp -rv $ezidamBinary $out
cp -rv $ezidamAssets $out
'';
};
# Docker image
dockerImage = pkgs.dockerTools.buildLayeredImage {
# Meta
@ -102,20 +122,29 @@
contents = pkgs.buildEnv {
name = "image-root";
paths = [
ezidam
ezidamBinary
ezidamAssets
];
pathsToLink = [ "/bin" ];
};
# Container config
config = {
Cmd = [ "${ezidam}/bin/ezidam" ];
Cmd = [ "${ezidamBinary}/bin/ezidam" ];
Env = [
"EZIDAM_TEMPLATE_DIR=${ezidamAssetTemplate}"
"EZIDAM_STATIC_DIR=${ezidamAssetStatic}"
];
};
};
in
{
apps.default = {
type = "app";
program = "${ezidamBinary}/bin/ezidam";
};
packages = {
inherit ezidam dockerImage;
default = ezidam;