nixconfig/modules/server/docker/authentik.nix

102 lines
3.3 KiB
Nix
Raw Normal View History

2024-04-20 12:58:28 +02:00
{ config, pkgs, ... }:
let serverCfg = config.syscfg.server;
in {
2023-12-01 12:54:30 +01:00
project.name = "Authentik";
networks = {
internal = {
internal = true;
external = false;
};
external = { external = true; };
};
services = {
auth_postgresql.service = {
image = "postgres:14-alpine";
container_name = "auth_postgresql";
restart = "unless-stopped";
networks = [ "internal" ];
volumes = [ ];
environment = {
POSTGRES_PASSWORD = "/run/secrets/AUTHENTIK_POSTGRESQL__PASSWORD";
POSTGRES_USER = "authentik";
POSTGRES_DB = "authentik";
};
};
auth_redis.service = {
image = "redis:alpine";
container_name = "auth_redis";
restart = "unless-stopped";
networks = [ "internal" ];
volumes = [ ];
environment = { };
labels = { "traefik.enable" = "false"; };
};
auth_server.service = {
image = "ghcr.io/goauthentik/server:latest";
container_name = "auth_server";
restart = "unless-stopped";
networks = [ "internal" "external" ];
volumes = [
2024-04-20 12:58:28 +02:00
"${serverCfg.dataPath}/authentik/media:/media"
"${serverCfg.dataPath}/authentik/templates:/templates"
2023-12-01 12:54:30 +01:00
];
environment = {
"AUTHENTIK_REDIS__HOST" = "auth_redis";
"AUTHENTIK_POSTGRESQL__HOST" = "auth_postgresql";
"AUTHENTIK_POSTGRESQL__USER" = "authentik";
"AUTHENTIK_POSTGRESQL__NAME" = "authentik";
2023-11-17 09:55:29 +01:00
"AUTHENTIK_POSTGRESQL__PASSWORD" = "AUTHENTIK_DB_PASSWORD";
2023-12-07 01:07:31 +01:00
"AUTHENTIK_SECRET_KEY" = "AUTHENTIK_SECRET_KEY";
2024-04-20 12:58:28 +02:00
"AUTHENTIK_EMAIL__HOST" = "${serverCfg.mailDomain}";
2023-12-01 12:54:30 +01:00
"AUTHENTIK_EMAIL__PORT" = "587";
2024-04-20 12:58:28 +02:00
"AUTHENTIK_EMAIL__USERNAME" = "noreply@${serverCfg.hostDomain}";
2023-12-07 01:07:31 +01:00
"AUTHENTIK_EMAIL__PASSWORD" = "AUTHENTIK_EMAIL_PASSWORD";
2023-12-01 12:54:30 +01:00
"AUTHENTIK_EMAIL__USE_TLS" = "true";
"AUTHENTIK_EMAIL__USE_SSL" = "false";
"AUTHENTIK_EMAIL__TIMEOUT" = "10";
2024-04-20 12:58:28 +02:00
"AUTHENTIK_EMAIL__FROM" = "sso@noreply.${serverCfg.hostDomain}";
2023-12-01 12:54:30 +01:00
};
labels = {
"traefik.enable" = "true";
"traefik.http.routers.sso.entrypoints" = "web-secure";
2024-04-20 12:58:28 +02:00
"traefik.http.routers.sso.rule" = "Host(`sso.${serverCfg.hostDomain}`)";
2023-12-01 12:54:30 +01:00
"traefik.http.routers.sso.tls" = "true";
"traefik.http.services.sso.loadbalancer.server.port" = "9000";
"traefik.docker.network" = "external";
};
command = "server";
2024-04-20 12:58:28 +02:00
ports = [
2023-12-01 12:54:30 +01:00
"9999:9000" # host:container
];
};
auth_worker.service = {
image = "ghcr.io/goauthentik/server:latest";
container_name = "auth_worker";
restart = "unless-stopped";
networks = [ "internal" ];
volumes = [
2024-04-20 12:58:28 +02:00
"${serverCfg.dataPath}/authentik/media:/media"
"${serverCfg.dataPath}/authentik/templates:/templates"
2023-12-01 12:54:30 +01:00
"/var/run/docker.sock:/var/run/docker.sock"
];
environment = {
"AUTHENTIK_REDIS__HOST" = "auth_redis";
"AUTHENTIK_POSTGRESQL__HOST" = "auth_postgresql";
"AUTHENTIK_POSTGRESQL__USER" = "authentik";
"AUTHENTIK_POSTGRESQL__NAME" = "authentik";
2023-11-17 09:55:29 +01:00
"AUTHENTIK_POSTGRESQL__PASSWORD" = "AUTHENTIK_DB_PASSWORD";
2023-12-07 01:07:31 +01:00
"AUTHENTIK_SECRET_KEY" = "AUTHENTIK_SECRET_KEY";
2023-12-01 12:54:30 +01:00
};
labels = { "traefik.enable" = "false"; };
command = "worker";
user = "root";
};
};
}