wip
Some checks failed
Build and push nixos-based docker container / build (push) Failing after 2s

This commit is contained in:
James Andariese 2024-08-04 01:47:08 -05:00
parent 27588a1d35
commit e7a318b482

View File

@ -2,19 +2,63 @@
let
name = "node-red";
packages =
with pkgs;
with nodePackages;
with dockerTools;
[
less
bashInteractive
coreutils
nodejs
findutils
npm
node-red
usrBinEnv
binSh
caCertificates
fakeNss
#ungoogled-chromium
];
entrypoint = pkgs.writeShellApplication {
name = "entrypoint";
runtimeInputs = with pkgs; with nodePackages; [
node-red
#ungoogled-chromium
];
runtimeInputs = packages;
text = ''
node-red -u "''${DATA-/data}" -s "''${SETTINGS-/data/settings.js}"
DATA="''${DATA-/data}"
cd "$DATA"
node-red -u "$DATA" -s "''${SETTINGS-/data/settings.js}"
'';
};
linkPackageToRoot = p: ''
for wbin in bin sbin;do
for f in ${p}/$wbin/*;do
if [ -x "$f" ];then
ln -sf "$f" /"$wbin"/"$f"
fi
done
done
'';
in pkgs.dockerTools.streamLayeredImage {
inherit name;
contents = packages;
config.Cmd = [ "${entrypoint}/bin/entrypoint" ];
config.Workdir = "/data";
config.Env = with pkgs; [ "HOME=/data" ];
fakeRootCommands = ''
# ${pkgs.runtimeShell}
mkdir -p /tmp
chmod 1777 /tmp
${pkgs.dockerTools.shadowSetup}
groupadd -r node-red
useradd -r -g node-red node-red
mkdir -p /data
chown -R node-red:node-red /data
chmod -R 750 /data
'' + (lib.strings.concatStringsSep "\n" (map linkPackageToRoot packages) );
extraCommands = ''
find / > files-that-existed-at-extraCommands-time.txt || true
'';
}