]>
Commit | Line | Data |
---|---|---|
1 | { lib, pkgs, config, ... }: | |
2 | let | |
3 | secrets = config.myEnv.websites.isabelle.aten_integration; | |
4 | app = pkgs.webapps.aten.override { environment = secrets.environment; }; | |
5 | cfg = config.myServices.websites.isabelle.aten_integration; | |
6 | pcfg = config.services.phpApplication; | |
7 | in { | |
8 | options.myServices.websites.isabelle.aten_integration.enable = lib.mkEnableOption "enable Aten's website in integration"; | |
9 | ||
10 | config = lib.mkIf cfg.enable { | |
11 | services.duplyBackup.profiles.aten_dev.rootDir = app.varDir; | |
12 | services.phpApplication.apps.aten_dev = { | |
13 | websiteEnv = "integration"; | |
14 | httpdUser = config.services.httpd.Inte.user; | |
15 | httpdGroup = config.services.httpd.Inte.group; | |
16 | httpdWatchFiles = [ | |
17 | config.secrets.fullPaths."webapps/${app.environment}-aten" | |
18 | ]; | |
19 | inherit (app) webRoot varDir; | |
20 | inherit app; | |
21 | serviceDeps = [ "postgresql.service" ]; | |
22 | preStartActions = [ | |
23 | "APP_ENV=${app.environment} ./bin/console --env=${app.environment} cache:clear --no-warmup" | |
24 | ]; | |
25 | phpOpenbasedir = [ "/tmp" ]; | |
26 | phpPool = { | |
27 | "php_admin_value[upload_max_filesize]" = "20M"; | |
28 | "php_admin_value[post_max_size]" = "20M"; | |
29 | #"php_admin_flag[log_errors]" = "on"; | |
30 | "pm" = "ondemand"; | |
31 | "pm.max_children" = "5"; | |
32 | "pm.process_idle_timeout" = "60"; | |
33 | }; | |
34 | phpEnv = { | |
35 | SYMFONY_DEBUG_MODE = "yes"; | |
36 | }; | |
37 | }; | |
38 | ||
39 | secrets.keys = [{ | |
40 | dest = "webapps/${app.environment}-aten"; | |
41 | user = config.services.httpd.Inte.user; | |
42 | group = config.services.httpd.Inte.group; | |
43 | permissions = "0400"; | |
44 | text = let | |
45 | # cf: | |
46 | # https://secure.php.net/manual/fr/function.parse-url.php | |
47 | # vendor/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php#parseDatabaseUrlQuery | |
48 | psql_url = with secrets.postgresql; "pdo-pgsql://${user}:${password}@invalid:${port}/${database}?host=${socket}"; | |
49 | in '' | |
50 | SetEnv APP_ENV "${app.environment}" | |
51 | SetEnv APP_SECRET "${secrets.secret}" | |
52 | SetEnv DATABASE_URL "${psql_url}" | |
53 | ''; | |
54 | }]; | |
55 | services.websites.env.integration.vhostConfs.aten_dev = { | |
56 | certName = "integration"; | |
57 | addToCerts = true; | |
58 | hosts = [ "dev.aten.pro" ]; | |
59 | root = pcfg.webappDirs.aten_dev; | |
60 | extraConfig = [ | |
61 | '' | |
62 | <FilesMatch "\.php$"> | |
63 | SetHandler "proxy:unix:${pcfg.phpListenPaths.aten_dev}|fcgi://localhost" | |
64 | </FilesMatch> | |
65 | ||
66 | Include ${config.secrets.fullPaths."webapps/${app.environment}-aten"} | |
67 | ||
68 | <Location /> | |
69 | Use LDAPConnect | |
70 | Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu | |
71 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>" | |
72 | </Location> | |
73 | ||
74 | <Location /backend> | |
75 | Use LDAPConnect | |
76 | Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu | |
77 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>" | |
78 | </Location> | |
79 | ||
80 | <Directory ${pcfg.webappDirs.aten_dev}> | |
81 | Options Indexes FollowSymLinks MultiViews Includes | |
82 | AllowOverride All | |
83 | Require all granted | |
84 | DirectoryIndex index.php | |
85 | FallbackResource /index.php | |
86 | </Directory> | |
87 | '' | |
88 | ]; | |
89 | }; | |
90 | }; | |
91 | } |