X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=nixops%2Fmodules%2Fwebsites%2Fludivine%2Fludivinecassal.nix;h=c12d89ca4ac4183d81fd63edf8d11c7747e884bc;hb=1b3154e40a568a296c74759d68827366b5f26da9;hp=e17a64eed0dbdfa09f936e2f04f1a3831155a090;hpb=7ebcaad53a3261d8a4aefd8a64c5c7d9d8ac2fa0;p=perso%2FImmae%2FConfig%2FNix.git diff --git a/nixops/modules/websites/ludivine/ludivinecassal.nix b/nixops/modules/websites/ludivine/ludivinecassal.nix index e17a64e..c12d89c 100644 --- a/nixops/modules/websites/ludivine/ludivinecassal.nix +++ b/nixops/modules/websites/ludivine/ludivinecassal.nix @@ -3,8 +3,12 @@ let ludivinecassal = { config }: rec { environment = config.environment; varDir = "/var/lib/ludivinecassal_${environment}"; - configRoot = - writeText "parameters.yml" '' + keys = [{ + dest = "webapps/${environment}-ludivinecassal"; + user = apache.user; + group = apache.group; + permissions = "0400"; + text = '' # This file is auto-generated during the composer install parameters: database_host: ${config.mysql.host} @@ -14,7 +18,7 @@ let 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} @@ -34,7 +38,21 @@ let sass: ${sass}/bin/sass ruby: ${ruby}/bin/ruby ''; + }]; 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}-ludivinecassal > ${varDir}/currentKey + fi + ''; + serviceDeps = [ "mysql.service" ]; socket = "/var/run/phpfpm/ludivinecassal-${environment}.sock"; pool = '' listen = ${socket} @@ -45,7 +63,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] = "${configRoot}:${webappDir}:${varDir}:/tmp" + php_admin_value[open_basedir] = "/var/secrets/webapps/${environment}-ludivinecassal:${webappDir}:${varDir}:/tmp" php_admin_value[session.save_path] = "${varDir}/phpSessions" ${if environment == "dev" then '' pm = ondemand @@ -60,10 +78,12 @@ let pm.max_spare_servers = 3 ''}''; }; - apache = { + apache = rec { user = "wwwrun"; group = "wwwrun"; modules = [ "proxy_fcgi" ]; + webappName = "ludivine_${environment}"; + root = "/run/current-system/webapps/${webappName}"; vhostConf = '' SetHandler "proxy:unix:${phpFpm.socket}|fcgi://localhost" @@ -76,7 +96,7 @@ let ErrorDocument 401 "" - + Options Indexes FollowSymLinks MultiViews Includes AllowOverride None Require all granted @@ -119,7 +139,7 @@ let '' else '' Use Stats ludivinecassal.com - + Options Indexes FollowSymLinks MultiViews Includes AllowOverride All Require all granted @@ -133,13 +153,6 @@ let install -m 0755 -o ${apache.user} -g ${apache.group} -d ${varDir} install -m 0755 -o ${apache.user} -g ${apache.group} -d ${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 ( @@ -149,14 +162,22 @@ let noDev = (environment == "prod"); preInstall = '' export SYMFONY_ENV="${environment}" - ln -sf ${configRoot} app/config/parameters.yml + cp app/config/parameters.yml.dist app/config/parameters.yml + cat >> app/config/parameters.yml <