[Symfony] Ma configuration EasyDeploy
Publié le 01/12/2019 • Actualisé le 01/12/2019
Voici ma configuration de déploiement pour le bundle EasyDeploy. Et bien, ça n'a pas été aussi facile que ça mais ça marche bien désormais 🙃. J'ai pu supprimer le petit hack pour modifier une variable privée de la classe de configuration afin que le déploiement puisse fonctionner. Cliquez sur le lien "Plus sur Stackoverflow" pour comprendre pourquoi. Tout le processus de déploiement prend exactement une minute (ça inclue le téléchargement de toutes les dépendances composer
) et, cerise sur le gâteau, à la fin, j'entends mon Mac me dire "Déploiement terminé !" 😁
<?php
declare(strict_types=1);
// config/prod/deploy.php
use EasyCorp\Bundle\EasyDeployBundle\Configuration\DefaultConfiguration;
use EasyCorp\Bundle\EasyDeployBundle\Deployer\DefaultDeployer;
/*
* @see https://github.com/EasyCorp/easy-deploy-bundle/blob/master/doc/default-deployer.md
*/
return new class extends DefaultDeployer {
public function configure(): DefaultConfiguration
{
$sharedFilesAndDir = [
'.env',
'.npmrc',
'config/secrets/prod/prod.decrypt.private.php',
'config/jwt/private.pem',
'config/jwt/public.pem',
'public/media',
];
return $this->getConfigBuilder()
->server('deploy-agent@vps.ovh.net:21') // fake server name
->useSshAgentForwarding(true)
->deployDir('/var/www/strangebuzz.com') // fake path
->repositoryUrl('git@github.com:strangebuzz/strangebuzz.git') // fake repo
->repositoryBranch('master') // 🙃
->keepReleases(2)
->remoteComposerBinaryPath('/usr/bin/composer')
->composerInstallFlags('--no-interaction --quiet --optimize-autoloader')
->controllersToRemove(['public/index.php']) // to know why I remove this, check out https://www.strangebuzz.com/en/blog/on-hiding-the-main-symfony-front-controller
->sharedFilesAndDirs($sharedFilesAndDir)
->writableDirs(['public/media'])
->fixPermissionsWithChown('www-data');
}
/**
* Uncomment the redis flush only if there is a database schema change.
*/
public function beforeStartingDeploy(): void
{
// flush Doctrine cache metadata the hard way
// $this->runRemote('redis-cli -p 6379 flushall');
}
public function beforePublishing(): void
{
$this->runRemote('yarn install');
$this->runRemote('make encore');
$this->runRemote('make reload');
$this->runRemote('make fix-perms');
$this->runRemote('composer dump-env prod');
$this->runRemote('touch /var/cache/mod_pagespeed/cache.flush');
}
/**
* Run some local or remote commands after the deployment is finished.
*/
public function beforeFinishingDeploy(): void
{
$this->runLocal('say "Déploiment terminé."');
}
};
Plus sur Stackoverflow Lire la doc Snippet aléatoire
A vous de jouer !
Ces articles vous ont été utiles ? Vous pouvez m'aider à votre tour de plusieurs manières : (cliquez sur le lien "reply" dans à droite pour me contacter )
- Me remonter des erreurs ou typos.
- Me remonter des choses qui pourraient être améliorées.
- Aimez et repostez !
- Suivez moi sur Bluesky 🦋
- Inscrivez-vous au flux RSS.
- Cliquez sur les boutons Plus sur Stackoverflow pour me faire gagner des badges "annonceur" 🏅.
Merci et à très bientôt sur Strangebuzz ! 😉