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

  1. Install Craft CMS locally
  2. Setup an app at fortrabbit
  3. Deploy code via Git ← you are here
  4. Database syncing
  5. 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
shell

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
shell

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.

Written by a human. Review, grammar checks and typo fixes by AI.

AI use & editorial processEdit on GitHub ↗