]>
Commit | Line | Data |
---|---|---|
1 | { lib, pkgs, config, ... }: | |
2 | let | |
3 | secrets = config.myEnv.websites.ludivine.production; | |
4 | app = pkgs.callPackage ./app { | |
5 | composerEnv = pkgs.composerEnv.override { php = pkgs.php72; }; | |
6 | environment = secrets.environment; | |
7 | varDir = "/var/lib/ludivine_production"; | |
8 | secretsPath = config.secrets.fullPaths."websites/ludivine/production"; | |
9 | }; | |
10 | pcfg = config.services.phpApplication; | |
11 | cfg = config.myServices.websites.ludivine.production; | |
12 | in { | |
13 | options.myServices.websites.ludivine.production.enable = lib.mkEnableOption "enable Ludivine's website in production"; | |
14 | ||
15 | config = lib.mkIf cfg.enable { | |
16 | services.webstats.sites = [ { name = "ludivinecassal.com"; } ]; | |
17 | services.phpApplication.apps.ludivine_production = { | |
18 | websiteEnv = "production"; | |
19 | httpdUser = config.services.httpd.Prod.user; | |
20 | httpdGroup = config.services.httpd.Prod.group; | |
21 | inherit (app) webRoot varDir; | |
22 | varDirPaths = { | |
23 | "tmp" = "0700"; | |
24 | }; | |
25 | inherit app; | |
26 | serviceDeps = [ "mysql.service" ]; | |
27 | preStartActions = [ | |
28 | "./bin/console --env=${app.environment} cache:clear --no-warmup" | |
29 | ]; | |
30 | phpOpenbasedir = [ "/tmp" ]; | |
31 | phpPool = { | |
32 | "php_admin_value[upload_max_filesize]" = "20M"; | |
33 | "php_admin_value[post_max_size]" = "20M"; | |
34 | #"php_admin_flag[log_errors]" = "on"; | |
35 | "pm" = "dynamic"; | |
36 | "pm.max_children" = "20"; | |
37 | "pm.start_servers" = "2"; | |
38 | "pm.min_spare_servers" = "1"; | |
39 | "pm.max_spare_servers" = "3"; | |
40 | }; | |
41 | phpWatchFiles = [ | |
42 | config.secrets.fullPaths."websites/ludivine/production" | |
43 | ]; | |
44 | phpEnv = { | |
45 | PATH = lib.makeBinPath [ | |
46 | # below ones don't need to be in the PATH but they’re used in | |
47 | # secrets | |
48 | pkgs.imagemagick pkgs.sass pkgs.ruby | |
49 | ]; | |
50 | }; | |
51 | phpPackage = pkgs.php72; | |
52 | }; | |
53 | ||
54 | secrets.keys."websites/ludivine/production" = { | |
55 | user = config.services.httpd.Prod.user; | |
56 | group = config.services.httpd.Prod.group; | |
57 | permissions = "0400"; | |
58 | text = '' | |
59 | # This file is auto-generated during the composer install | |
60 | parameters: | |
61 | database_host: ${secrets.mysql.host} | |
62 | database_port: ${secrets.mysql.port} | |
63 | database_name: ${secrets.mysql.database} | |
64 | database_user: ${secrets.mysql.user} | |
65 | database_password: ${secrets.mysql.password} | |
66 | database_server_version: ${pkgs.mariadb.mysqlVersion} | |
67 | mailer_transport: smtp | |
68 | mailer_host: 127.0.0.1 | |
69 | mailer_user: null | |
70 | mailer_password: null | |
71 | secret: ${secrets.secret} | |
72 | ldap_host: ldap.immae.eu | |
73 | ldap_port: 636 | |
74 | ldap_version: 3 | |
75 | ldap_ssl: true | |
76 | ldap_tls: false | |
77 | ldap_user_bind: 'uid={username},ou=users,dc=immae,dc=eu' | |
78 | ldap_base_dn: 'dc=immae,dc=eu' | |
79 | ldap_search_dn: '${secrets.ldap.dn}' | |
80 | ldap_search_password: '${secrets.ldap.password}' | |
81 | ldap_search_filter: '${secrets.ldap.filter}' | |
82 | leapt_im: | |
83 | binary_path: ${pkgs.imagemagick}/bin | |
84 | assetic: | |
85 | sass: ${pkgs.sass}/bin/sass | |
86 | ruby: ${pkgs.ruby}/bin/ruby | |
87 | ''; | |
88 | }; | |
89 | ||
90 | services.websites.env.production.vhostConfs.ludivine_production = { | |
91 | certName = "ludivine"; | |
92 | certMainHost = "ludivinecassal.com"; | |
93 | hosts = ["ludivinecassal.com" "www.ludivinecassal.com" ]; | |
94 | root = app.webRoot; | |
95 | extraConfig = [ | |
96 | '' | |
97 | RewriteEngine on | |
98 | RewriteCond "%{HTTP_HOST}" "!^ludivinecassal\.com$" [NC] | |
99 | RewriteRule ^(.+)$ https://ludivinecassal.com$1 [R=302,L] | |
100 | ||
101 | <FilesMatch "\.php$"> | |
102 | SetHandler "proxy:unix:${pcfg.phpListenPaths.ludivine_production}|fcgi://localhost" | |
103 | </FilesMatch> | |
104 | ||
105 | Use Stats ludivinecassal.com | |
106 | ||
107 | <Directory ${app.webRoot}> | |
108 | Options Indexes FollowSymLinks MultiViews Includes | |
109 | AllowOverride All | |
110 | Require all granted | |
111 | </Directory> | |
112 | '' | |
113 | ]; | |
114 | }; | |
115 | }; | |
116 | } |