[Symfony] My EasyDeploy configuration
Published on 2019-12-01 • Modified on 2019-12-01
This is my deploy configuration for the EasyDeploy bundle. I finally could delete a "small" hack to modify a private property to make it work. Click on the "more on Stackoverflow" to understand why. The deployment takes one minute exactly (That includes installing all the composer
dependencies) and "cerise sur le gateau", at the end, I have my Mac saying "Deployment finished!". π
<?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Γ©."');
}
};
More on Stackoverflow Read the doc Random snippet
Call to action
Did you like this post? You can help me back in several ways: (use the "reply" link on the right to comment or to contact me )
- Report any error/typo.
- Report something that could be improved.
- Like and repost!
- Follow me on Bluesky π¦
- Subscribe to the RSS feed.
- Click on the More on Stackoverflow buttons to make me win "Announcer" badges π .
Thank you for reading! And see you soon on Strangebuzz! π