feat(dgsi): Make it work

This commit is contained in:
Tom Hubrecht 2024-09-25 13:57:55 +02:00
parent 2b75890752
commit bdeb55f9ec
Signed by: thubrecht
SSH key fingerprint: SHA256:r+nK/SIcWlJ0zFZJGHtlAoRwq1Rm+WcKAm5ADYMoQPc
4 changed files with 68 additions and 12 deletions

View file

@ -2,6 +2,7 @@
config, config,
lib, lib,
pkgs, pkgs,
utils,
sources, sources,
... ...
}: }:
@ -40,6 +41,7 @@ let
# Local packages # Local packages
ps.django-allauth ps.django-allauth
ps.django-allauth-cas ps.django-allauth-cas
ps.django-browser-reload
ps.django-bulma-forms ps.django-bulma-forms
ps.django-sass-processor ps.django-sass-processor
ps.django-sass-processor-dart-sass ps.django-sass-processor-dart-sass
@ -101,12 +103,27 @@ in
SECRET_KEY = config.age.secrets."dgsi-secret_key_file".path; SECRET_KEY = config.age.secrets."dgsi-secret_key_file".path;
KANIDM_AUTH_TOKEN = config.age.secrets."dgsi-kanidm_auth_token_file".path; KANIDM_AUTH_TOKEN = config.age.secrets."dgsi-kanidm_auth_token_file".path;
KANIDM_SECRET = config.age.secrets."dgsi-kanidm_secret_file".path; KANIDM_SECRET = config.age.secrets."dgsi-kanidm_secret_file".path;
EMAIL_HOST_PASSWORD = config.age.secrets."dgsi-email_host_password_file".path;
}; };
RuntimeDirectory = "django-apps/dgsi"; RuntimeDirectory = "django-apps/dgsi";
StateDirectory = "django-dgsi"; StateDirectory = "django-apps/dgsi";
UMask = "0027"; UMask = "0027";
User = "dj-dgsi"; User = "dj-dgsi";
WorkingDirectory = "${sources.dgsi}/src"; Group = "django-apps";
WorkingDirectory = sources.dgsi;
ExecReload = "${lib.getExe' pkgs.coreutils "kill"} -s HUP $MAINPID";
KillMode = "mixed";
Type = "notify";
ExecStart = utils.escapeSystemdExecArgs [
(lib.getExe' pythonEnv "gunicorn")
"--workers"
4
"--bind"
"unix:/run/django-apps/dgsi.sock"
"--pythonpath"
"src"
"app.wsgi"
];
}; };
environment = { environment = {
@ -114,15 +131,27 @@ in
"profil.dgnum.eu" "profil.dgnum.eu"
"dgsi.dgnum.eu" "dgsi.dgnum.eu"
]; ];
DGSI_STATIC_ROOT = staticDrv; DGSI_EMAIL_HOST_USER = "web-services@infra.dgnum.eu";
DGSI_EMAIL_USE_SSL = builtins.toJSON true;
DGSI_FROM_EMAIL = "La Délégation Générale Numérique <dgsi@infra.dgnum.eu>";
DGSI_SERVER_EMAIL = "dgsi@infra.dgnum.eu";
DGSI_KANIDM_CLIENT = "dgsi_test";
DGSI_KANIDM_URI = "https://sso.dgnum.eu";
DGSI_MEDIA_ROOT = "/var/lib/django-apps/dgsi/media"; DGSI_MEDIA_ROOT = "/var/lib/django-apps/dgsi/media";
DGSI_STATIC_ROOT = "${staticDrv}/static";
DGSI_DATABASES = builtins.toJSON {
default = {
ENGINE = "django.db.backends.postgresql";
NAME = "dj-dgsi";
};
};
DJANGO_SETTINGS_MODULE = "app.settings";
}; };
path = [ pythonEnv ]; path = [ pythonEnv ];
script = '' preStart = ''
python3 manage.py migrate python3 src/manage.py migrate --no-input
gunicorn --pythonpath ${sources.dgsi}/src --bind unix:/run/django-apps/dgsi.sock --workers=4 app.wsgi
''; '';
}; };
}; };
@ -155,10 +184,10 @@ in
services = { services = {
postgresql = { postgresql = {
ensureDatabases = [ "dgsi" ]; ensureDatabases = [ "dj-dgsi" ];
ensureUsers = [ ensureUsers = [
{ {
name = "dgsi"; name = "dj-dgsi";
ensureDBOwnership = true; ensureDBOwnership = true;
} }
]; ];
@ -168,8 +197,6 @@ in
enableACME = true; enableACME = true;
forceSSL = true; forceSSL = true;
serverAliases = [ "dgsi.dgnum.eu" ];
locations = { locations = {
"/".proxyPass = "http://unix:/run/django-apps/dgsi.sock"; "/".proxyPass = "http://unix:/run/django-apps/dgsi.sock";
"/static/".root = staticDrv; "/static/".root = staticDrv;

View file

@ -0,0 +1,28 @@
age-encryption.org/v1
-> ssh-ed25519 jIXfPA CQffZYaxexZ2f+HeNj+SHeSak0kzNPiq6ExW7t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q uWIz5shMnsLXsh160cCW8E6kh9v4LPunOonugjWdSEY
5aRrIB5gxIplVWDGeMQ6g09togku6LxWRxBP7FbRNU0
-> ssh-ed25519 tDqJRg G8rNpeGY29czDVMvvt4LZ7nffZ/JAHDzxuIs7C/0SEM
HowgAvrQQcvUx93ZdK5q2bSsJDqaOxFf+x/lwTRss4I
--- ktcSPCC1TpguyYJ2ua7IuGcEw+Z9YuqjzcmH18abjo4
<EFBFBD><20><>ゥ煩 ネ9<1猤カワ簒<EFBE9C>pWJSWpsV/ム#<23>ウリ9タ{タ゚cHB<><42><EFBFBD>5<EFBFBD>ャ^ァ

View file

@ -6,6 +6,7 @@ in
lib.setDefault { inherit publicKeys; } [ lib.setDefault { inherit publicKeys; } [
"arkheon-env_file" "arkheon-env_file"
"bupstash-put_key" "bupstash-put_key"
"dgsi-email_host_password_file"
"dgsi-kanidm_auth_token_file" "dgsi-kanidm_auth_token_file"
"dgsi-kanidm_secret_file" "dgsi-kanidm_secret_file"
"dgsi-secret_key_file" "dgsi-secret_key_file"

View file

@ -57,9 +57,9 @@
"url": "https://git.dgnum.eu/DGNum/dgsi.git" "url": "https://git.dgnum.eu/DGNum/dgsi.git"
}, },
"branch": "main", "branch": "main",
"revision": "8a46e4ddb522a145046d9a5bfc729a8e46d99f44", "revision": "5381b0379b112778cee05f7fa5dc989da96a77ba",
"url": null, "url": null,
"hash": "1blyh1xcppcb6qjaww8aw00c4nh1dl50i64bf6ampj0idx0y93qh" "hash": "0r7k9mp04qwffj5f1xnqzfiwls6higjcj1radr3gh53sslvp36ca"
}, },
"disko": { "disko": {
"type": "GitRelease", "type": "GitRelease",