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