Deploy Craft CMS 6 to fortrabbit

Published

Updated

Git deployment for Craft CMS 6 on fortrabbit, with the build and post-deploy commands of the software template.

Install and deploy run down

  1. Install Craft CMS 6 locally
  2. Set up an app at fortrabbit
  3. Deploy code via Git ← you are here
  4. Database syncing
  5. Assets

Git deployment

With the repository connected to the app, a git push to the deployment branch starts a deployment. The deploy button in the dashboard deploys the latest commit. See the deployment intro for how it works.

Settings from the template

Version 6 of the Craft CMS software template sets the deployment:

Craft CMS 6

DeploymentValue
Root pathpublic
Deploy strategyreplace
Excluded paths/storage/node_modules
Build commandscomposer install --no-dev --prefer-dist --no-interaction --no-ansi --no-progress
Post-deploy commandsmkdir -p storage/framework/{sessions,views,cache}php artisan migrate --forcephp artisan storage:link --forceif php artisan craft:install:check; then php artisan craft:up; fiif php artisan craft:install:check; then php artisan craft:clear-caches/all; fi
Environment variablesValue
APP_DEBUGfalse
APP_ENVproduction
APP_KEY!RANDOM_KEY!
APP_URLhttps://${FORTRABBIT_MAIN_DOMAIN}
LOG_CHANNELstack
LOG_STACKstderr
Database environment variablesValue
DB_CONNECTIONmysql
DB_DATABASE${FORTRABBIT_DB_NAME}
DB_HOST${FORTRABBIT_DB_HOST}
DB_PASSWORD${FORTRABBIT_DB_PASSWORD}
DB_PORT${FORTRABBIT_DB_PORT}
DB_USERNAME${FORTRABBIT_DB_USER}

Change them in the deployment settings of the environment or with a deploy file. Add npm install and npm run build to the build commands for front-end assets built with Vite.

Notes

  • craft:install:check skips craft:up while Craft is not installed, so the first deployment to an empty database passes.
  • The replace strategy deletes files that are not in the repository, except in storage. storage:link creates the public/storage link for assets again.
  • The project config in config/craft/project/ comes from the repository. Make settings changes locally and commit them.

Written by humans and AI in collaboration.

AI use & editorial processEdit on GitHub ↗