Deploy a monorepo on fortrabbit

Published

Updated

🌳

Organize multiple projects in one repo.

A monorepo keeps several projects in one git repository. On fortrabbit, each environment deploys one folder of that repository, set with the git source directory.

About monorepos

A monorepo stores several related projects in one git repository, often with shared dependencies and releases in step:

monorepo
 - packages (shared)
 - app-1
 - app-2
raw

Tools such as Turborepo or Nx manage the shared parts, see monorepo.tools. Monorepos are common in JavaScript, less so in PHP. fortrabbit's own frontend is a JavaScript monorepo.

A web project with a JavaScript frontend and a PHP backend in one repository works the same way, see headless workflows.

Monorepos on fortrabbit

Git deployment is built around one repository per project, and handles a monorepo with these settings per environment:

  • Git source directory: the folder that gets deployed, for example /apps/website-1
  • Build commands: run from the repository root, so a build step can reach the shared packages before it changes into the project folder
  • Branch and automatic deployment: connect the same repository and branch to several environments

An environment deploys from one repository. Git submodules and subtrees are untested with Git deployment.

CMS multi-site

Craft CMS, Kirby, WordPress and Statamic can run several sites from one installation. That is an alternative to a monorepo when the sites share content and templates. See project organization for the trade-offs.

External pipelines

A CI service such as GitHub Actions can build the project and upload it with rsync over SSH, authenticated with a deploy key.

Written by humans and AI in collaboration.

AI use & editorial processEdit on GitHub ↗