Simple bash scripts to deploy a Symfony application

Published on 2019-07-08 • Modified on 2019-12-11

[Edit 2019-12-11] I don't use these scripts anymore. Please use a real deployment tool, you won't regret it. You can find my EasyDeploy config in this snippet.


Here are two simple bash scripts I used a long time ago on this blog to deploy this application. This is a side project so I don't need something complicated. I am calling these scripts from my MakeFile you can find here. The first script just do a minor update (eg: you have corrected a typo or added a minor feature). The second one is a full deployment, it will install all the composer dependencies, modify your database schema for a major feature, etc... In both cases, I am using a simple git pull. The website is "down" for some seconds while deploying, but that's not a problem in this case as it's a personal project.
PS: Uncomment the mod_pagespeed line if don't use it.


#!/bin/bash
# bin/prod/update.sh
echo "##########################################################################"
echo "# Update the prod...                                                     #"
echo "##########################################################################"
git checkout public/index_dev.php
git pull
rm -rf var/cache/* var/logs/*
php bin/console cache:warmup
chmod -R 777 var/*
touch /var/cache/mod_pagespeed/cache.flush
rm public/index_dev.php
echo -e " --> DONE\n"

#!/bin/bash
# bin/prod/deploy.sh
echo "##########################################################################"
echo "# Full deploy...                                                         #"
echo "##########################################################################"

git checkout public/index_dev.php
git pull
php composer.phar install --no-interaction --optimize-autoloader
php bin/console cache:clear --no-warmup
php bin/console cache:warmup
php bin/console doctrine:cache:clear-metadata
#php bin/console doctrine:migrations:migrate --no-interaction --env=prod --no-debug
chmod -R 777 var/*
touch /var/cache/mod_pagespeed/cache.flush
rm public/index_dev.php

echo -e " --> DONE\n"

 More on Stackoverflow   Read the doc  Random snippet

  Work with me!