Deploy Craft CMS to fortrabbit
Published
Updated
Set up automatic git code deployment for your Craft CMS application hosted on fortrabbit.
Install and deploy run down
- Install Craft CMS locally
- Setup an app at fortrabbit
- Deploy code via Git ← you are here
- Database syncing
- Assets syncing
Git deployment
With the repository connected to the app, every git push to the deployment branch deploys Craft CMS to fortrabbit. The deploy button in the dashboard starts a deployment of the latest commit as well. See the deployment intro for how it works.
Deployment configuration
The stack detector and the Craft CMS software template set up the deployment when the app is created. Change it later in the deployment settings of the environment or with a deploy file.
Build commands
Build commands run before the new code goes live:
composer install --no-dev --prefer-dist --no-interaction --no-ansi --no-progress
# Only with a package.json and a lock file in the repository
npm install
npm run build
Post-deploy commands
Post-deploy commands run once the new code is live. They apply database migrations and the project config, then clear the caches:
php craft migrate/all
php craft project-config/apply
php craft clear-caches/all
Deployment strategy
Craft CMS apps use the merge strategy: files on the environment that are not in the repository stay, so asset volumes survive a deployment wherever they sit. A replace pattern for /config/project makes sure project config files deleted from the repository are deleted on the environment too.
The replace strategy also works, with an exclude pattern for every asset volume.