This commit is contained in:
parent
27588a1d35
commit
c6155b03cd
58
docker.nix
58
docker.nix
|
@ -1,20 +1,64 @@
|
||||||
{ config, pkgs, ...}:
|
{ config, pkgs, lib, ...}:
|
||||||
|
|
||||||
let
|
let
|
||||||
name = "node-red";
|
name = "node-red";
|
||||||
|
packages =
|
||||||
|
with nodePackages;
|
||||||
|
with ;
|
||||||
|
with pkgs;
|
||||||
|
[
|
||||||
|
less
|
||||||
|
bashInteractive
|
||||||
|
coreutils
|
||||||
|
nodejs
|
||||||
|
findutils
|
||||||
|
nodePackages.npm
|
||||||
|
nodePackages.node-red
|
||||||
|
dockerTools.usrBinEnv
|
||||||
|
dockerTools.binSh
|
||||||
|
dockerTools.caCertificates
|
||||||
|
dockerTools.fakeNss
|
||||||
|
#ungoogled-chromium
|
||||||
|
];
|
||||||
entrypoint = pkgs.writeShellApplication {
|
entrypoint = pkgs.writeShellApplication {
|
||||||
name = "entrypoint";
|
name = "entrypoint";
|
||||||
|
|
||||||
runtimeInputs = with pkgs; with nodePackages; [
|
runtimeInputs = packages;
|
||||||
node-red
|
|
||||||
#ungoogled-chromium
|
|
||||||
];
|
|
||||||
|
|
||||||
text = ''
|
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"/
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
'';
|
||||||
in pkgs.dockerTools.streamLayeredImage {
|
in pkgs.dockerTools.streamLayeredImage {
|
||||||
inherit name;
|
inherit name;
|
||||||
|
contents = packages;
|
||||||
config.Cmd = [ "${entrypoint}/bin/entrypoint" ];
|
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
|
||||||
|
'';
|
||||||
|
extraCommands = ''
|
||||||
|
#find / > files-that-existed-at-extraCommands-time.txt || true
|
||||||
|
${pkgs.lib.strings.concatStringsSep "\n" (map linkPackageToRoot packages)}
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user