]>
Commit | Line | Data |
---|---|---|
9d90e7e2 | 1 | { lib, writeText, fetchedGitPrivate, stdenv, php, git, cacert, phpPackages, ruby, sass, imagemagick }: |
e42ba74f | 2 | let |
9d90e7e2 IB |
3 | ludivinecassal = { config }: rec { |
4 | environment = config.environment; | |
e42ba74f | 5 | varDir = "/var/lib/ludivinecassal_${environment}"; |
e42ba74f | 6 | configRoot = |
e42ba74f IB |
7 | writeText "parameters.yml" '' |
8 | # This file is auto-generated during the composer install | |
9 | parameters: | |
10 | database_host: db-1.immae.eu | |
11 | database_port: null | |
9d90e7e2 IB |
12 | database_name: ${config.mysql.name} |
13 | database_user: ${config.mysql.user} | |
14 | database_password: ${config.mysql.password} | |
e42ba74f IB |
15 | mailer_transport: smtp |
16 | mailer_host: mail.immae.eu | |
17 | mailer_user: null | |
18 | mailer_password: null | |
9d90e7e2 | 19 | secret: ${config.secret} |
e42ba74f IB |
20 | ldap_host: ldap.immae.eu |
21 | ldap_port: 636 | |
22 | ldap_version: 3 | |
23 | ldap_ssl: true | |
24 | ldap_tls: false | |
25 | ldap_user_bind: 'uid={username},ou=users,dc=immae,dc=eu' | |
26 | ldap_base_dn: 'dc=immae,dc=eu' | |
9d90e7e2 IB |
27 | ldap_search_dn: '${config.ldap.dn}' |
28 | ldap_search_password: '${config.ldap.password}' | |
29 | ldap_search_filter: '${config.ldap.search}' | |
e42ba74f IB |
30 | leapt_im: |
31 | binary_path: ${imagemagick}/bin | |
32 | assetic: | |
33 | sass: ${sass}/bin/sass | |
34 | ruby: ${ruby}/bin/ruby | |
35 | ''; | |
36 | phpFpm = rec { | |
37 | socket = "/var/run/phpfpm/ludivinecassal-${environment}.sock"; | |
38 | pool = '' | |
39 | listen = ${socket} | |
40 | user = ${apache.user} | |
41 | group = ${apache.group} | |
42 | listen.owner = ${apache.user} | |
43 | listen.group = ${apache.group} | |
44 | php_admin_value[upload_max_filesize] = 20M | |
45 | php_admin_value[post_max_size] = 20M | |
46 | ;php_admin_flag[log_errors] = on | |
47 | php_admin_value[open_basedir] = "${configRoot}:${webappDir}:${varDir}:/tmp" | |
c8e019b6 | 48 | php_admin_value[session.save_path] = "${varDir}/phpSessions" |
e42ba74f IB |
49 | ${if environment == "dev" then '' |
50 | pm = ondemand | |
51 | pm.max_children = 5 | |
52 | pm.process_idle_timeout = 60 | |
53 | env[SYMFONY_DEBUG_MODE] = "yes" | |
54 | '' else '' | |
55 | pm = dynamic | |
56 | pm.max_children = 20 | |
57 | pm.start_servers = 2 | |
58 | pm.min_spare_servers = 1 | |
59 | pm.max_spare_servers = 3 | |
60 | ''}''; | |
61 | }; | |
62 | apache = { | |
63 | user = "wwwrun"; | |
64 | group = "wwwrun"; | |
65 | modules = [ "proxy_fcgi" ]; | |
66 | vhostConf = '' | |
67 | <FilesMatch "\.php$"> | |
68 | SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" | |
69 | </FilesMatch> | |
70 | ||
71 | ${if environment == "dev" then '' | |
72 | <Location /> | |
73 | Use LDAPConnect | |
74 | Require ldap-group cn=ludivine.immae.eu,cn=httpd,ou=services,dc=immae,dc=eu | |
75 | ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://ludivinecassal.com\"></html>" | |
76 | </Location> | |
77 | ||
78 | <Directory ${webRoot}> | |
79 | Options Indexes FollowSymLinks MultiViews Includes | |
80 | AllowOverride None | |
81 | Require all granted | |
82 | ||
83 | DirectoryIndex app_dev.php | |
84 | ||
85 | <IfModule mod_negotiation.c> | |
86 | Options -MultiViews | |
87 | </IfModule> | |
88 | ||
89 | <IfModule mod_rewrite.c> | |
90 | RewriteEngine On | |
91 | ||
92 | RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$ | |
93 | RewriteRule ^(.*) - [E=BASE:%1] | |
94 | ||
95 | # Maintenance script | |
96 | RewriteCond %{DOCUMENT_ROOT}/maintenance.php -f | |
97 | RewriteCond %{SCRIPT_FILENAME} !maintenance.php | |
98 | RewriteRule ^.*$ %{ENV:BASE}/maintenance.php [R=503,L] | |
99 | ErrorDocument 503 /maintenance.php | |
100 | ||
101 | # Sets the HTTP_AUTHORIZATION header removed by Apache | |
102 | RewriteCond %{HTTP:Authorization} . | |
103 | RewriteRule ^ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] | |
104 | ||
105 | RewriteCond %{ENV:REDIRECT_STATUS} ^$ | |
106 | RewriteRule ^app_dev\.php(?:/(.*)|$) %{ENV:BASE}/$1 [R=301,L] | |
107 | ||
108 | # If the requested filename exists, simply serve it. | |
109 | # We only want to let Apache serve files and not directories. | |
110 | RewriteCond %{REQUEST_FILENAME} -f | |
111 | RewriteRule ^ - [L] | |
112 | ||
113 | # Rewrite all other queries to the front controller. | |
114 | RewriteRule ^ %{ENV:BASE}/app_dev.php [L] | |
115 | </IfModule> | |
116 | ||
117 | </Directory> | |
118 | '' else '' | |
34e2fd14 IB |
119 | Use Stats ludivinecassal.com |
120 | ||
e42ba74f IB |
121 | <Directory ${webRoot}> |
122 | Options Indexes FollowSymLinks MultiViews Includes | |
123 | AllowOverride All | |
124 | Require all granted | |
125 | </Directory> | |
126 | ''} | |
127 | ''; | |
128 | }; | |
129 | activationScript = { | |
130 | deps = [ "wrappers" ]; | |
131 | text = '' | |
132 | install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} | |
6de72a20 | 133 | install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir}/tmp |
c8e019b6 | 134 | install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions |
e42ba74f IB |
135 | if [ ! -f "${varDir}/currentWebappDir" -o \ |
136 | "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then | |
137 | pushd ${webappDir} > /dev/null | |
138 | $wrapperDir/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup | |
139 | popd > /dev/null | |
140 | echo -n "${webappDir}" > ${varDir}/currentWebappDir | |
141 | fi | |
142 | ''; | |
143 | }; | |
091ae734 | 144 | webappDir = stdenv.mkDerivation (fetchedGitPrivate ./ludivinecassal.json // rec { |
a5365ec3 IB |
145 | # /!\ miniatures and data need to be in the same dir due to a |
146 | # bug in leapt.im (searches for data/../miniatures) | |
e42ba74f IB |
147 | buildPhase = '' |
148 | export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt | |
149 | export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt | |
150 | ||
151 | ln -sf ${configRoot} app/config/parameters.yml | |
152 | sed -i -e "/Incenteev..ParameterHandler..ScriptHandler::buildParameters/d" composer.json | |
153 | ${if environment == "dev" then '' | |
154 | composer install | |
155 | '' else '' | |
156 | SYMFONY_ENV=prod composer install --no-dev | |
157 | ''} | |
158 | rm -rf var | |
159 | ln -sf ../../../../../${varDir} var | |
160 | ''; | |
161 | installPhase = '' | |
162 | cp -a . $out | |
163 | ''; | |
164 | buildInputs = [ | |
165 | php git cacert phpPackages.composer sass | |
166 | ]; | |
167 | }); | |
168 | webRoot = "${webappDir}/web"; | |
169 | }; | |
170 | in | |
171 | ludivinecassal |