X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=nixops%2Fmodules%2Fwebsites%2Fpiedsjaloux%2Fpiedsjaloux.nix;h=5461e5dad1c98eef979890b38974b4a9a229b127;hb=0ede7366409e14482017f70f1efc53426279b8d0;hp=1b53c4a5022e0531ca3cf2591512aa869d2b53c7;hpb=01f21083a897b86bf148f1d2bb9c8edca4d3786a;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/nixops/modules/websites/piedsjaloux/piedsjaloux.nix b/nixops/modules/websites/piedsjaloux/piedsjaloux.nix index 1b53c4a..5461e5d 100644 --- a/nixops/modules/websites/piedsjaloux/piedsjaloux.nix +++ b/nixops/modules/websites/piedsjaloux/piedsjaloux.nix @@ -3,18 +3,22 @@ let piedsjaloux = { config }: rec { environment = config.environment; varDir = "/var/lib/piedsjaloux_${environment}"; - configRoot = - writeText "parameters.yml" '' + keys = [{ + dest = "webapps/${environment}-piedsjaloux"; + user = apache.user; + group = apache.group; + permissions = "0400"; + text = '' # This file is auto-generated during the composer install parameters: - database_host: db-1.immae.eu - database_port: null + database_host: ${config.mysql.host} + database_port: ${config.mysql.port} database_name: ${config.mysql.name} database_user: ${config.mysql.user} database_password: ${config.mysql.password} database_server_version: ${pkgs.mariadb.mysqlVersion} mailer_transport: smtp - mailer_host: mail.immae.eu + mailer_host: 127.0.0.1 mailer_user: null mailer_password: null secret: ${config.secret} @@ -22,7 +26,21 @@ let leapt_im: binary_path: ${imagemagick}/bin ''; + }]; phpFpm = rec { + preStart = '' + if [ ! -f "${varDir}/currentWebappDir" -o \ + ! -f "${varDir}/currentKey" -o \ + "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ] \ + || ! sha512sum -c --status ${varDir}/currentKey; then + pushd ${webappDir} > /dev/null + /run/wrappers/bin/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup + popd > /dev/null + echo -n "${webappDir}" > ${varDir}/currentWebappDir + sha512sum /var/secrets/webapps/${environment}-piedsjaloux > ${varDir}/currentKey + fi + ''; + serviceDeps = [ "mysql.service" ]; socket = "/var/run/phpfpm/piedsjaloux-${environment}.sock"; pool = '' listen = ${socket} @@ -33,8 +51,9 @@ let php_admin_value[upload_max_filesize] = 20M php_admin_value[post_max_size] = 20M ;php_admin_flag[log_errors] = on - php_admin_value[open_basedir] = "${configRoot}:${webappDir}:${varDir}:/tmp" + php_admin_value[open_basedir] = "/var/secrets/webapps/${environment}-piedsjaloux:${webappDir}:${varDir}:/tmp" php_admin_value[session.save_path] = "${varDir}/phpSessions" + env[PATH] = ${lib.makeBinPath [ pkgs.apg pkgs.unzip ]} ${if environment == "dev" then '' pm = ondemand pm.max_children = 5 @@ -48,10 +67,12 @@ let pm.max_spare_servers = 3 ''}''; }; - apache = { + apache = rec { user = "wwwrun"; group = "wwwrun"; modules = [ "proxy_fcgi" ]; + webappName = "piedsjaloux_${environment}"; + root = "/run/current-system/webapps/${webappName}"; vhostConf = '' SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" @@ -64,7 +85,7 @@ let ErrorDocument 401 "" - + Options Indexes FollowSymLinks MultiViews Includes AllowOverride None Require all granted @@ -107,7 +128,7 @@ let '' else '' Use Stats piedsjaloux.fr - + Options Indexes FollowSymLinks MultiViews Includes AllowOverride All Require all granted @@ -121,13 +142,6 @@ let install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} \ ${varDir}/tmp install -m 0750 -o ${apache.user} -g ${apache.group} -d ${varDir}/phpSessions - if [ ! -f "${varDir}/currentWebappDir" -o \ - "${webappDir}" != "$(cat ${varDir}/currentWebappDir 2>/dev/null)" ]; then - pushd ${webappDir} > /dev/null - $wrapperDir/sudo -u wwwrun ./bin/console --env=${environment} cache:clear --no-warmup - popd > /dev/null - echo -n "${webappDir}" > ${varDir}/currentWebappDir - fi ''; }; webappDir = composerEnv.buildPackage ( @@ -143,9 +157,9 @@ let postInstall = '' cd $out rm app/config/parameters.yml - ln -sf ${configRoot} app/config/parameters.yml + ln -sf /var/secrets/webapps/${environment}-piedsjaloux app/config/parameters.yml rm -rf var/{logs,cache,data,miniatures,tmp} - ln -sf ../../../../../../../${varDir}/{logs,cache,data,miniatures,tmp} var/ + ln -sf ${varDir}/{logs,cache,data,miniatures,tmp} var/ ''; }); webRoot = "${webappDir}/web";