Last active
March 28, 2024 15:45
-
-
Save rap2hpoutre/95d51c8d3d82777cae14 to your computer and use it in GitHub Desktop.
Laravel Forge deploy script without downtime
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stop script on error signal | |
set -e | |
# remove old deployment folders | |
if [ -d "/home/forge/deploy" ]; then | |
rm -R /home/forge/deploy | |
fi | |
if [ -d "/home/forge/backup" ]; then | |
rm -R /home/forge/backup | |
fi | |
cp -R /home/forge/default /home/forge/deploy | |
# Update | |
cd /home/forge/deploy | |
git pull origin master | |
composer install | |
php artisan migrate --force | |
# Switch (downtime for microseconds) | |
mv /home/forge/default /home/forge/backup | |
mv /home/forge/deploy /home/forge/default | |
# Reset opcache | |
echo "<?php opcache_reset(); echo 'opcache reset' . PHP_EOL; ?>" > /home/forge/default/public/opcachereset.php | |
curl http://localhost/opcachereset.php | |
rm /home/forge/default/public/opcachereset.php |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment