Adopts secret-based environment configs

- Generates Cloudflare configuration at build time
- Replaces static environment files with secret-driven configuration for containers
- Unifies environment settings for authentik and komodo
This commit is contained in:
Chris Toph 2025-04-22 21:12:08 -04:00
parent 39b2c02bba
commit f5ed26ade7
3 changed files with 19 additions and 24 deletions

View file

@ -1,9 +1,16 @@
{ {
config,
lib,
pkgs, pkgs,
config,
... ...
}: }:
let
cloudflare = pkgs.writeTextFile {
name = "cloudflare.ini";
text = ''
CF_DNS_API_TOKEN=${config.secretsSpec.api.cloudflare}
'';
};
in
{ {
# letsencrypt # letsencrypt
@ -12,7 +19,7 @@
defaults = { defaults = {
email = "chris@toph.cc"; email = "chris@toph.cc";
dnsProvider = "cloudflare"; dnsProvider = "cloudflare";
environmentFile = ./cloudflare.ini; environmentFile = cloudflare;
}; };
certs = { certs = {
"goldenlemon.cc" = { "goldenlemon.cc" = {

View file

@ -4,14 +4,13 @@
let let
# Only available in the Komodo LXC # Only available in the Komodo LXC
DockerStorage = "/mnt/DockerStorage/komodo/stacks/authentik"; DockerStorage = "/mnt/DockerStorage/komodo/stacks/authentik";
env = config.secretsSpec.docker.authentik;
in in
{ {
# Containers # Containers
virtualisation.oci-containers.containers."authentik-postgresql" = { virtualisation.oci-containers.containers."authentik-postgresql" = {
image = "docker.io/library/postgres:16-alpine"; image = "docker.io/library/postgres:16-alpine";
environmentFiles = [ environment = env;
./authentik.env
];
volumes = [ volumes = [
"${DockerStorage}/database:/var/lib/postgresql/data:rw" "${DockerStorage}/database:/var/lib/postgresql/data:rw"
]; ];
@ -48,9 +47,7 @@ in
}; };
virtualisation.oci-containers.containers."authentik-redis" = { virtualisation.oci-containers.containers."authentik-redis" = {
image = "docker.io/library/redis:alpine"; image = "docker.io/library/redis:alpine";
environmentFiles = [ environment = env;
./authentik.env
];
volumes = [ volumes = [
"${DockerStorage}/redis:/data:rw" "${DockerStorage}/redis:/data:rw"
]; ];
@ -94,9 +91,7 @@ in
}; };
virtualisation.oci-containers.containers."authentik-server" = { virtualisation.oci-containers.containers."authentik-server" = {
image = "ghcr.io/goauthentik/server:2024.12.2"; image = "ghcr.io/goauthentik/server:2024.12.2";
environmentFiles = [ environment = env;
./authentik.env
];
volumes = [ volumes = [
"${DockerStorage}/custom-templates:/templates:rw" "${DockerStorage}/custom-templates:/templates:rw"
"${DockerStorage}/media:/media:rw" "${DockerStorage}/media:/media:rw"
@ -138,9 +133,7 @@ in
}; };
virtualisation.oci-containers.containers."authentik-worker" = { virtualisation.oci-containers.containers."authentik-worker" = {
image = "ghcr.io/goauthentik/server:2024.12.2"; image = "ghcr.io/goauthentik/server:2024.12.2";
environmentFiles = [ environment = env;
./authentik.env
];
volumes = [ volumes = [
"${DockerStorage}/certs:/certs:rw" "${DockerStorage}/certs:/certs:rw"
"${DockerStorage}/media:/media:rw" "${DockerStorage}/media:/media:rw"

View file

@ -8,14 +8,13 @@
let let
# Only available in the Komodo LXC # Only available in the Komodo LXC
DockerStorage = "/mnt/DockerStorage/komodo"; DockerStorage = "/mnt/DockerStorage/komodo";
env = config.secretsSpec.docker.komodo;
in in
{ {
# Containers # Containers
virtualisation.oci-containers.containers."komodo-core" = { virtualisation.oci-containers.containers."komodo-core" = {
image = "ghcr.io/moghtech/komodo-core:latest"; image = "ghcr.io/moghtech/komodo-core:latest";
environmentFiles = [ environment = env;
./komodo.env
];
volumes = [ volumes = [
"${DockerStorage}/cache:/repo-cache:rw" "${DockerStorage}/cache:/repo-cache:rw"
]; ];
@ -61,9 +60,7 @@ in
virtualisation.oci-containers.containers."komodo-mongo" = { virtualisation.oci-containers.containers."komodo-mongo" = {
image = "mongo"; image = "mongo";
environmentFiles = [ environment = env;
./komodo.env
];
volumes = [ volumes = [
"${DockerStorage}/mongo/config:/data/configdb:rw" "${DockerStorage}/mongo/config:/data/configdb:rw"
"${DockerStorage}/mongo/data:/data/db:rw" "${DockerStorage}/mongo/data:/data/db:rw"
@ -110,9 +107,7 @@ in
virtualisation.oci-containers.containers."komodo-periphery" = { virtualisation.oci-containers.containers."komodo-periphery" = {
image = "ghcr.io/moghtech/komodo-periphery:latest"; image = "ghcr.io/moghtech/komodo-periphery:latest";
environmentFiles = [ environment = env;
./komodo.env
];
volumes = [ volumes = [
"/proc:/proc:rw" "/proc:/proc:rw"
"/var/run/docker.sock:/var/run/docker.sock:rw" "/var/run/docker.sock:/var/run/docker.sock:rw"