Monorepos

It's a trend to organize multiple projects into one Git repo. What to consider when it comes to deployment and hosting monorepos.

# About monorepos

A monorepo (monolithic repository) stores multiple related projects in a single Git repository, potentially enabling shared dependencies and coordinated releases:

mono-repo
 - dependencies (shared)
 - app-1
   - dependencies (individual)
 - app-2
  - dependencies (individual)
raw

There are specific tools to help working with the shared dependencies. A good overview can be found at monorepo.tools. The projects of a monorepo usually share the software stack, not only the same programming language, but also a framework on top of that.

At fortrabbit, we use a monorepo for our JavaScript based frontend stack. Not only Node modules can be shared directly, but also web components can be shared across the different web properties easily.

# PHP monorepos

Monorepos are not that popular in PHP, at least at the time of this writing. Symfony and Laravel have basic monorepo structure support. PHP monorepos require consideration to ensure each application can be deployed independently while leveraging shared code effectively.

# Multi stack web projects in one Git repo

Like outlined with project organization, some web projects may include a frontend and a backend stack in one repo.

website-project
  - frontend (JS)
  - backend (PHP)
raw

That's not really a classical monorepo, but more like a repo that contains two different projects.

# CMS multi-site features

An alternative approach to host multiple different projects with one code base can be a multi-site feature, Craft CMS, Kirby WordPress and Statamic support that.

# Monorepo support on fortrabbit

The fortrabbit git deployment features are mainly designed for classical polyrepo (or multirepo) use cases, where each web project will have it's own Git repo.

# Available features

  • Add the same repo to multiple apps
  • Add the same branch to multiple environments
  • Define which path of the repo is deployed where
  • Enable/disable automatic deployments

# Features not available

  • Add multiple repos to one app
  • Using Git subtree or Git submodules

# Using external build pipelines

The builtin deployment tools are just one option to deploy code. It's also possible to connect fortrabbit to external CI/CD systems such as GitHub Actions by providing third party services direct SSH access through deploy keys.

Found a tpyo?Edit