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