influx to docker
This commit is contained in:
@@ -5,23 +5,7 @@ let
|
||||
listNames = config.syscfg.server.db;
|
||||
containerNames = lib.concatMap (app: app.requires.databases) (builtins.attrValues config.syscfg.server.loadedContainers);
|
||||
allApps = lib.unique (listNames ++ containerNames);
|
||||
influxAdminTokenJson = pkgs.writeShellScript "influxdb3-admin-token-json" ''
|
||||
set -eu
|
||||
|
||||
token="''${INFLUXDB_TOKEN-''${INFLUXDB_TOKEN-}}"
|
||||
if [ -z "$token" ]; then
|
||||
echo "Missing INFLUXDB_TOKEN or INFLUXDB_TOKEN in ${config.sops.secrets."INFLUX".path}" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat > "$RUNTIME_DIRECTORY/admin-token.json" <<EOF
|
||||
{
|
||||
"token": "$token",
|
||||
"name": "admin",
|
||||
"description": "Admin token for automated deployment"
|
||||
}
|
||||
EOF
|
||||
'';
|
||||
in {
|
||||
config = lib.mkIf ( builtins.length allApps > 0) {
|
||||
services.postgresql = {
|
||||
@@ -56,31 +40,6 @@ in {
|
||||
bind = "*";
|
||||
settings.protected-mode = "no";
|
||||
};
|
||||
|
||||
systemd.services.influxdb3 = {
|
||||
description = "InfluxDB 3 Time Series Database Engine";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
environment = {
|
||||
INFLUXDB3_NODE_IDENTIFIER_PREFIX = "node0";
|
||||
INFLUXDB3_OBJECT_STORE = "file";
|
||||
INFLUXDB3_DATA_DIR = "${config.syscfg.server.path.data}/influxdb";
|
||||
INFLUXDB3_DB_DIR = "${config.syscfg.server.path.data}/influxdb";
|
||||
INFLUXDB3_ENABLE_INTERNAL_DB = "true";
|
||||
};
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
EnvironmentFile = config.sops.secrets."INFLUX".path;
|
||||
RuntimeDirectory = "influxdb3";
|
||||
ExecStartPre = influxAdminTokenJson;
|
||||
ExecStart = "${pkgs.influxdb3}/bin/influxdb3 serve --admin-token-file=%t/influxdb3/admin-token.json";
|
||||
Restart = "on-failure";
|
||||
StateDirectory = "influxdb3";
|
||||
PrivateTmp = true;
|
||||
NoNewPrivileges = true;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
systemd.services.postgresql-init = {
|
||||
description = "Custom Postgres Setup (Ownership & Passwords)";
|
||||
|
||||
Reference in New Issue
Block a user