-
-
Save tonioriol/e2f7d159e8905d69d2a9bd042f7b1778 to your computer and use it in GitHub Desktop.
Laravel Forge zero downtime deployment script
This file contains hidden or 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 | |
SITE="your-site-original-folder-name.com" | |
DEPL="/home/forge/deployments/${SITE}" | |
# create directory and any intermediate directories if don't exist | |
mkdir -p ${DEPL} | |
CUR="/home/forge/${SITE}" | |
NEW="${DEPL}/new" | |
BKP="${DEPL}/backup" | |
# remove old deployment folders | |
if [ -d ${NEW} ]; then | |
rm -R ${NEW} | |
fi | |
if [ -d ${BKP} ]; then | |
rm -R ${BKP} | |
fi | |
cp -R ${CUR} ${NEW} | |
cd ${NEW} | |
# REGULAR SCRIPT (git pull, whatever you do to build assets, reload php clean opcache...) | |
git pull origin develop | |
composer install --no-interaction --prefer-dist --optimize-autoloader --no-dev | |
echo "" | sudo -S service php7.1-fpm reload | |
# /REUGLAR SCRIPT | |
# Switch (downtime for microseconds) | |
mv ${CUR} ${BKP} | |
mv ${NEW} ${CUR} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I would make this one change on the
$SITE
variableSITE=${FORGE_SITE_PATH#"/home/forge/"}
That way, it's fully dynamic and you could copy/paste to a testing/prod environment without changing much.