Inspired by Capistrano https://github.com/capistrano/capistrano
- Zero Downtime - Gets everything ready, and then switches the
currentdirectory symbolic link - NPM Install
- Composer Install
- Persistant storage at /storage/
- 5 most recent releases are stored in /releases/ for quick rollback
- Latest live release activated at /current/
- Works on existing and already deployed projects
This deployment script organises deployment into a set of directories, each with its specific purpose:
- releases: This directory holds a number of past deployments. Each deployment creates a new subdirectory named after the timestamp of the release.
- storage: The storage directory is your Laravel storage directory designed for files and directories that must persist between deployments, such as user-uploaded assets, and logs.
- current: A symbolic link pointing to the latest release in the releases directory. This allows for quick rollbacks and minimal downtime during deployments.
- Create a site, the Web Directory must be set to
/current/public. - Setup up deployment of a laravel project.
- Once
deploymentstab appears, replace the deployment script with the one attached. Make sure to update the first line! - Deploy again.
If the script detects that app directory exists inside BASE_DIR, it will run through a setup process where it creates a releases structure and moves your existing Laravel project into it.
Every time you deploy, this script will copy your old release, git pull/clean and prepare it for going live.
Once it is finished, it will change BASE_DIR/current symbolic link to your latest release resulting in a zero downtime deployment.
We keep a copy of artisan and your .env file in BASE_DIR/ so that Forge GUI can read and run commands.
If you have an issue with a deployment, you can quickly roll back by swapping the symbolic link:
ln -sfn /home/forge/site.com/releases/oldrelease /home/forge/site.com/current
Bash is not my primary language, if you have any improvements, please let me know in the comments.
Thanks a lot for this, i was going crazy trying to fix my deploy script <3