]> git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/websites/ludivine/production.nix
Add alternate cloud storage for daily backups
[perso/Immae/Config/Nix.git] / modules / private / websites / ludivine / production.nix
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.duplyBackup.profiles.ludivine_production.rootDir = app.varDir;
17 services.duplyBackup.profiles.ludivine_production.remotes = ["eriomem" "ovh"];
18 services.webstats.sites = [ { name = "ludivinecassal.com"; } ];
19 services.phpApplication.apps.ludivine_production = {
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" ];
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 };
43 phpWatchFiles = [
44 config.secrets.fullPaths."websites/ludivine/production"
45 ];
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 };
53 phpPackage = pkgs.php72;
54 };
55
56 secrets.keys = [
57 {
58 dest = "websites/ludivine/production";
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}
67 database_name: ${secrets.mysql.database}
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}'
85 ldap_search_filter: '${secrets.ldap.filter}'
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 ];
94
95 services.websites.env.production.vhostConfs.ludivine_production = {
96 certName = "ludivine";
97 certMainHost = "ludivinecassal.com";
98 hosts = ["ludivinecassal.com" "www.ludivinecassal.com" ];
99 root = pcfg.webappDirs.ludivine_production;
100 extraConfig = [
101 ''
102 RewriteEngine on
103 RewriteCond "%{HTTP_HOST}" "!^ludivinecassal\.com$" [NC]
104 RewriteRule ^(.+)$ https://ludivinecassal.com$1 [R=302,L]
105
106 <FilesMatch "\.php$">
107 SetHandler "proxy:unix:${pcfg.phpListenPaths.ludivine_production}|fcgi://localhost"
108 </FilesMatch>
109
110 Use Stats ludivinecassal.com
111
112 <Directory ${pcfg.webappDirs.ludivine_production}>
113 Options Indexes FollowSymLinks MultiViews Includes
114 AllowOverride All
115 Require all granted
116 </Directory>
117 ''
118 ];
119 };
120 };
121 }