X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=nixops%2Fmodules%2Fwebsites%2Fconnexionswing%2Fconnexionswing.nix;h=60ddb6388ba11b29ba6a7dc2d5ea92aea98f7c9f;hb=1b3154e40a568a296c74759d68827366b5f26da9;hp=c1781841db51d16dadd1041e909953fbbf1bb6cc;hpb=a754e9dbf5d6c35398f3c4ec52c3daf5f8ed2dd3;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/nixops/modules/websites/connexionswing/connexionswing.nix b/nixops/modules/websites/connexionswing/connexionswing.nix index c178184..60ddb63 100644 --- a/nixops/modules/websites/connexionswing/connexionswing.nix +++ b/nixops/modules/websites/connexionswing/connexionswing.nix @@ -3,11 +3,11 @@ let connexionswing = { config }: rec { environment = config.environment; varDir = "/var/lib/connexionswing_${environment}"; - keys."${environment}-connexionswing" = { - destDir = "/run/keys/webapps"; + keys = [{ + dest = "webapps/${environment}-connexionswing"; user = apache.user; group = apache.group; - permissions = "0700"; + permissions = "0400"; text = '' # This file is auto-generated during the composer install parameters: @@ -31,8 +31,21 @@ let arguments: ['/run/wrappers/bin/sendmail -bs'] '' else ""} ''; - }; + }]; 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}-connexionswing > ${varDir}/currentKey + fi + ''; + serviceDeps = [ "mysql.service" ]; socket = "/var/run/phpfpm/connexionswing-${environment}.sock"; phpConfig = '' extension=${phpPackages.imagick}/lib/php/extensions/imagick.so @@ -46,7 +59,7 @@ 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] = "/run/wrappers/bin/sendmail:/run/keys/webapps/${environment}-connexionswing:${webappDir}:${varDir}:/tmp" + php_admin_value[open_basedir] = "/run/wrappers/bin/sendmail:/var/secrets/webapps/${environment}-connexionswing:${webappDir}:${varDir}:/tmp" php_admin_value[session.save_path] = "${varDir}/phpSessions" ${if environment == "dev" then '' pm = ondemand @@ -150,13 +163,6 @@ let ${varDir}/uploads \ ${varDir}/var 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 ( @@ -171,7 +177,7 @@ let cd $out ${if environment == "prod" then "php ./bin/console assetic:dump --env=prod --no-debug" else ""} rm app/config/parameters.yml - ln -sf /run/keys/webapps/${environment}-connexionswing app/config/parameters.yml + ln -sf /var/secrets/webapps/${environment}-connexionswing app/config/parameters.yml rm -rf var/{logs,cache} ln -sf ${varDir}/var/{logs,cache} var/ ln -sf ${varDir}/{medias,uploads} web/images/