From 87d648485e97675a3f0c31ad7cb231c72b681ce9 Mon Sep 17 00:00:00 2001 From: soraefir Date: Fri, 5 Jun 2026 21:42:46 +0200 Subject: [PATCH] influx to docker --- modules/server/containers/apps/influx.nix | 49 ++++++++++++++--------- modules/server/database/default.nix | 41 ------------------- 2 files changed, 30 insertions(+), 60 deletions(-) diff --git a/modules/server/containers/apps/influx.nix b/modules/server/containers/apps/influx.nix index 1350fc1..55a6e40 100644 --- a/modules/server/containers/apps/influx.nix +++ b/modules/server/containers/apps/influx.nix @@ -22,22 +22,25 @@ in { }]; containers = { - # db = builder.mkContainer { - # subdomain = containerCfg.subdomain; - # image = "influxdata/influxdb:3.0"; - # port = 8181; - # secret = name; - # extraEnv = { - # INFLUXD_DB_PATH = "/db"; - # INFLUXD_CONFIG_PATH = "/config"; - # }; - # overrides = { - # volumes = [ - # "${serverCfg.path.data}/influxdb:/db:rw" - # "${serverCfg.path.config}/influxdb:/config:ro" - # ]; - # }; - # }; + db = builder.mkContainer { + subdomain = containerCfg.subdomain; + image = "influxdb:3-core"; + port = 8181; + secret = name; + extraEnv = { + INFLUXD_DB_PATH = "/db"; + INFLUXD_CONFIG_PATH = "/config"; + }; + overrides = { + cmd = [ "influxdb3" "serve" "--node-id=node0" "--data-dir=/var/lib/influxdb3/data" "--admin-token-file=/var/lib/influxdb3/token.json" ]; + ports = [ "8181:8181" ]; + volumes = [ + "${serverCfg.path.data}/influxdb:/var/lib/influxdb3/data:rw" + "${serverCfg.path.config}/influxdb/config/admin-token.json:/var/lib/influxdb3/token.json:ro" + + ]; + }; + }; server = builder.mkContainer { tmpfs = true; @@ -47,10 +50,9 @@ in { secret = name; extraEnv = { DATABASE_URL = "/db/sqlite.db"; - DEFAULT_INFLUX_SERVER = "http://${builder.host}:8181"; + DEFAULT_INFLUX_SERVER = "http://influx-db:8181"; }; overrides = { - ports = [ "8888:8080" ]; cmd = [ "--mode=admin" ]; volumes = [ "${serverCfg.path.data}/influxdb:/db:rw" @@ -71,7 +73,16 @@ in { "DEFAULT_SERVER_NAME": "${serverCfg.domain}" } EOF - chmod -R 755 ${serverCfg.path.config}/influxdb + + cat > ${serverCfg.path.config}/influxdb/config/admin-token.json <&2 - exit 1 - fi - - cat > "$RUNTIME_DIRECTORY/admin-token.json" < 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)";