1 { lib, writeText, fetchedGitPrivate, stdenv, php, git, cacert, phpPackages, yarn }:
3 aten = { config }: rec {
4 environment = config.environment;
5 varDir = "/var/lib/aten_${environment}";
7 socket = "/var/run/phpfpm/aten-${environment}.sock";
11 group = ${apache.group}
12 listen.owner = ${apache.user}
13 listen.group = ${apache.group}
14 php_admin_value[upload_max_filesize] = 20M
15 php_admin_value[post_max_size] = 20M
16 ;php_admin_flag[log_errors] = on
17 php_admin_value[open_basedir] = "${webappDir}:${varDir}:/tmp"
18 php_admin_value[session.save_path] = "${varDir}/phpSessions"
19 ${if environment == "dev" then ''
22 pm.process_idle_timeout = 60
23 env[SYMFONY_DEBUG_MODE] = "yes"
28 pm.min_spare_servers = 1
29 pm.max_spare_servers = 3
35 modules = [ "proxy_fcgi" ];
38 SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost"
41 SetEnv APP_ENV "${environment}"
42 SetEnv APP_SECRET "${config.secret}"
43 SetEnv DATABASE_URL "${config.psql_url}"
45 ${if environment == "dev" then ''
48 Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
49 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
54 Require ldap-group cn=dev.aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
55 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
62 Require ldap-group cn=aten.pro,cn=httpd,ou=services,dc=immae,dc=eu
63 ErrorDocument 401 "<html><meta http-equiv=\"refresh\" content=\"0;url=https://aten.pro\"></html>"
67 <Directory ${webRoot}>
68 Options Indexes FollowSymLinks MultiViews Includes
71 DirectoryIndex index.php
72 FallbackResource /index.php
77 deps = [ "wrappers" ];
79 install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir}
80 install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions
81 if [ ! -f "${varDir}/currentWebappDir" -o \
82 "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then
83 pushd ${webappDir} > /dev/null
84 $wrapperDir/sudo -u wwwrun APP_ENV=${environment} ./bin/console --env=${environment} cache:clear --no-warmup
86 echo -n "${webappDir}" > ${varDir}/currentWebappDir
90 webappDir = stdenv.mkDerivation (fetchedGitPrivate ./aten.json // rec {
92 export GIT_SSL_CAINFO=${cacert}/etc/ssl/certs/ca-bundle.crt
93 export SSL_CERT_FILE=${cacert}/etc/ssl/certs/ca-bundle.crt
94 export APP_ENV="${environment}"
95 export DATABASE_URL="${config.psql_url}"
96 export APP_SECRET="${config.secret}"
98 ${if environment == "dev" then ''
101 SYMFONY_ENV=prod composer install --no-dev
104 yarn run encore production
106 ln -sf ../../../../../${varDir} var
112 php git cacert phpPackages.composer yarn
115 webRoot = "${webappDir}/public";