diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-06-02 22:53:54 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-06-02 22:53:54 +0200 |
commit | 9f66adf4372a3b1c859dc053489f727aa360077e (patch) | |
tree | 1f1333f2fe59f5e77a6737c42dcd379f9c587a5c /modules/private/websites/ludivinecassal | |
parent | 1594c8da6fbb4ffa09ab970fb887cea61c572f60 (diff) | |
download | Nix-9f66adf4372a3b1c859dc053489f727aa360077e.tar.gz Nix-9f66adf4372a3b1c859dc053489f727aa360077e.tar.zst Nix-9f66adf4372a3b1c859dc053489f727aa360077e.zip |
Move integration php applications to dedicated module
Diffstat (limited to 'modules/private/websites/ludivinecassal')
-rw-r--r-- | modules/private/websites/ludivinecassal/integration.nix | 151 |
1 files changed, 127 insertions, 24 deletions
diff --git a/modules/private/websites/ludivinecassal/integration.nix b/modules/private/websites/ludivinecassal/integration.nix index bc05d9b..55f2432 100644 --- a/modules/private/websites/ludivinecassal/integration.nix +++ b/modules/private/websites/ludivinecassal/integration.nix | |||
@@ -1,36 +1,139 @@ | |||
1 | { lib, pkgs, config, myconfig, ... }: | 1 | { lib, pkgs, config, myconfig, ... }: |
2 | let | 2 | let |
3 | ludivinecassal = pkgs.callPackage ./builder.nix { | 3 | secrets = myconfig.env.websites.ludivinecassal.integration; |
4 | inherit (pkgs.webapps) ludivinecassal; | 4 | app = pkgs.webapps.ludivinecassal.override { environment = secrets.environment; }; |
5 | config = myconfig.env.websites.ludivinecassal.integration; | ||
6 | apacheUser = config.services.httpd.Inte.user; | ||
7 | apacheGroup = config.services.httpd.Inte.group; | ||
8 | }; | ||
9 | |||
10 | cfg = config.myServices.websites.ludivinecassal.integration; | 5 | cfg = config.myServices.websites.ludivinecassal.integration; |
6 | pcfg = config.services.phpApplication; | ||
11 | in { | 7 | in { |
12 | options.myServices.websites.ludivinecassal.integration.enable = lib.mkEnableOption "enable Ludivine's website in integration"; | 8 | options.myServices.websites.ludivinecassal.integration.enable = lib.mkEnableOption "enable Ludivine's website in integration"; |
13 | 9 | ||
14 | config = lib.mkIf cfg.enable { | 10 | config = lib.mkIf cfg.enable { |
15 | secrets.keys = ludivinecassal.keys; | 11 | services.phpApplication.apps.ludivinecassal_dev = { |
16 | 12 | websiteEnv = "integration"; | |
17 | systemd.services.phpfpm-ludivinecassal_dev.after = lib.mkAfter ludivinecassal.phpFpm.serviceDeps; | 13 | httpdUser = config.services.httpd.Inte.user; |
18 | systemd.services.phpfpm-ludivinecassal_dev.wants = ludivinecassal.phpFpm.serviceDeps; | 14 | httpdGroup = config.services.httpd.Inte.group; |
19 | systemd.services.phpfpm-ludivinecassal_dev.preStart = lib.mkAfter ludivinecassal.phpFpm.preStart; | 15 | inherit (app) webRoot varDir; |
20 | services.phpfpm.poolConfigs.ludivinecassal_dev = ludivinecassal.phpFpm.pool; | 16 | varDirPaths = { |
21 | system.activationScripts.ludivinecassal_dev = ludivinecassal.activationScript; | 17 | "tmp" = "0700"; |
22 | myServices.websites.webappDirs."${ludivinecassal.apache.webappName}" = ludivinecassal.app.webRoot; | 18 | }; |
23 | services.websites.env.integration.modules = ludivinecassal.apache.modules; | 19 | inherit app; |
24 | services.websites.env.integration.vhostConfs.ludivine = { | 20 | serviceDeps = [ "mysql.service" ]; |
25 | certName = "eldiron"; | 21 | preStartActions = [ |
22 | "./bin/console --env=${app.environment} cache:clear --no-warmup" | ||
23 | ]; | ||
24 | phpOpenbasedir = [ "/tmp" ]; | ||
25 | phpPool = '' | ||
26 | php_admin_value[upload_max_filesize] = 20M | ||
27 | php_admin_value[post_max_size] = 20M | ||
28 | ;php_admin_flag[log_errors] = on | ||
29 | pm = ondemand | ||
30 | pm.max_children = 5 | ||
31 | pm.process_idle_timeout = 60 | ||
32 | env[SYMFONY_DEBUG_MODE] = "yes" | ||
33 | ''; | ||
34 | phpWatchFiles = [ | ||
35 | config.secrets.fullPaths."webapps/${app.environment}-ludivinecassal" | ||
36 | ]; | ||
37 | }; | ||
38 | |||
39 | secrets.keys = [ | ||
40 | { | ||
41 | dest = "webapps/${app.environment}-ludivinecassal"; | ||
42 | user = config.services.httpd.Inte.user; | ||
43 | group = config.services.httpd.Inte.group; | ||
44 | permissions = "0400"; | ||
45 | text = '' | ||
46 | # This file is auto-generated during the composer install | ||
47 | parameters: | ||
48 | database_host: ${secrets.mysql.host} | ||
49 | database_port: ${secrets.mysql.port} | ||
50 | database_name: ${secrets.mysql.name} | ||
51 | database_user: ${secrets.mysql.user} | ||
52 | database_password: ${secrets.mysql.password} | ||
53 | database_server_version: ${pkgs.mariadb.mysqlVersion} | ||
54 | mailer_transport: smtp | ||
55 | mailer_host: 127.0.0.1 | ||
56 | mailer_user: null | ||
57 | mailer_password: null | ||
58 | secret: ${secrets.secret} | ||
59 | ldap_host: ldap.immae.eu | ||
60 | ldap_port: 636 | ||
61 | ldap_version: 3 | ||
62 | ldap_ssl: true | ||
63 | ldap_tls: false | ||
64 | ldap_user_bind: 'uid={username},ou=users,dc=immae,dc=eu' | ||
65 | ldap_base_dn: 'dc=immae,dc=eu' | ||
66 | ldap_search_dn: '${secrets.ldap.dn}' | ||
67 | ldap_search_password: '${secrets.ldap.password}' | ||
68 | ldap_search_filter: '${secrets.ldap.search}' | ||
69 | leapt_im: | ||
70 | binary_path: ${pkgs.imagemagick}/bin | ||
71 | assetic: | ||
72 | sass: ${pkgs.sass}/bin/sass | ||
73 | ruby: ${pkgs.ruby}/bin/ruby | ||
74 | ''; | ||
75 | } | ||
76 | ]; | ||
77 | |||
78 | services.websites.env.integration.vhostConfs.ludivinecassal_dev = { | ||
79 | certName = "eldiron"; | ||
26 | addToCerts = true; | 80 | addToCerts = true; |
27 | hosts = [ "ludivine.immae.eu" ]; | 81 | hosts = [ "ludivine.immae.eu" ]; |
28 | root = ludivinecassal.apache.root; | 82 | root = pcfg.webappDirs.ludivinecassal_dev; |
29 | extraConfig = [ ludivinecassal.apache.vhostConf ]; | 83 | extraConfig = [ |
30 | }; | 84 | '' |
31 | services.filesWatcher.phpfpm-ludivinecassal_dev = { | 85 | <FilesMatch "\.php$"> |
32 | restart = true; | 86 | SetHandler "proxy:unix:${pcfg.phpListenPaths.ludivinecassal_dev}|fcgi://localhost" |
33 | paths = [ "/var/secrets/webapps/${ludivinecassal.app.environment}-ludivinecassal" ]; | 87 | </FilesMatch> |
88 | |||
89 | <Location /> | ||
90 | Use LDAPConnect | ||
91 | Require ldap-group cn=ludivine.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu | ||
92 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://ludivinecassal.com\"></html>" | ||
93 | </Location> | ||
94 | |||
95 | <Directory ${pcfg.webappDirs.ludivinecassal_dev}> | ||
96 | Options Indexes FollowSymLinks MultiViews Includes | ||
97 | AllowOverride None | ||
98 | Require all granted | ||
99 | |||
100 | DirectoryIndex app_dev.php | ||
101 | |||
102 | <IfModule mod_negotiation.c> | ||
103 | Options -MultiViews | ||
104 | </IfModule> | ||
105 | |||
106 | <IfModule mod_rewrite.c> | ||
107 | RewriteEngine On | ||
108 | |||
109 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ | ||
110 | RewriteRule ^(.*) - [E=BASE:%1] | ||
111 | |||
112 | # Maintenance script | ||
113 | RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f | ||
114 | RewriteCond %{SCRIPT_FILENAME} !maintenance.php | ||
115 | RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L] | ||
116 | ErrorDocument 503 /maintenance.php | ||
117 | |||
118 | # Sets the HTTP_AUTHORIZATION header removed by Apache | ||
119 | RewriteCond %{HTTP:Authorization} . | ||
120 | RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | ||
121 | |||
122 | RewriteCond %{ENV:REDIRECT_STATUS} ^$ | ||
123 | RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] | ||
124 | |||
125 | # If the requested filename exists, simply serve it. | ||
126 | # We only want to let Apache serve files and not directories. | ||
127 | RewriteCond %{REQUEST_FILENAME} -f | ||
128 | RewriteRule ^ - [L] | ||
129 | |||
130 | # Rewrite all other queries to the front controller. | ||
131 | RewriteRule ^ %{ENV:BASE}/app_dev.php [L] | ||
132 | </IfModule> | ||
133 | |||
134 | </Directory> | ||
135 | '' | ||
136 | ]; | ||
34 | }; | 137 | }; |
35 | }; | 138 | }; |
36 | } | 139 | } |