autoupdates
This commit is contained in:
1 parent
6eb90819f0
commit
896d7480c1
7 files changed
+210
-12
No files matched your search
@@ -24,6 +24,41 @@
|
||||
};
|
||||
};
|
||||
|
||||
# Create the update service + timer for a group's autoUpdate config.
|
||||
mkUpdateUnits = groupName: grpCfg: composeBin: runtimeBin:
|
||||
let
|
||||
auCfg = grpCfg.autoUpdate;
|
||||
stateDir = grpCfg.stateDir;
|
||||
unitName = "container-services-${groupName}-update";
|
||||
composeCmd = "${composeBin} -p ${groupName} -f ${stateDir}/compose.yml";
|
||||
in
|
||||
{
|
||||
services."${unitName}" = {
|
||||
description = "Pull latest images and recreate container service group '${groupName}'";
|
||||
after = [ "container-services-${groupName}.service" ];
|
||||
requires = [ "container-services-${groupName}.service" ];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
ExecStart =
|
||||
[
|
||||
"${composeCmd} pull"
|
||||
"${composeCmd} up -d --remove-orphans"
|
||||
]
|
||||
++ lib.optional auCfg.pruneImages "${runtimeBin} image prune -f";
|
||||
};
|
||||
};
|
||||
timers."${unitName}" = {
|
||||
description = "Scheduled image update for container service group '${groupName}'";
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnCalendar = auCfg.onCalendar;
|
||||
RandomizedDelaySec = auCfg.randomizedDelaySec;
|
||||
Persistent = auCfg.persistent;
|
||||
Unit = "${unitName}.service";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
# Create a path unit that watches env files for changes.
|
||||
mkPathUnit = groupName: envFiles:
|
||||
lib.optionalAttrs (envFiles != [ ]) {
|
||||
|
||||
Reference in new issue
Block a user