Monorepo
A monorepo usually needs two things:
- install dependencies at the workspace root
- build a specific app from that workspace
The official recipes work well for single-app repositories. In a monorepo, the usual approach is to keep the transfer recipe (git or rsync) and override deploy:install / deploy:build so they run in the right directories.
Monorepo with Directus and Nuxt using git
This example deploys a monorepo that contains a Directus app in apps/cms and a Nuxt app in apps/web.
git clones the whole repository into the release, dependencies are installed once at the workspace root, nuxt builds the frontend from its app directory, directus runs its schema tasks from its own app directory, and Redis cache is flushed before publish.
typescript
import { defineConfig, task, cd, run, set, before } from '@catapultjs/deploy'
import '@catapultjs/deploy/recipes/directus'
import '@catapultjs/deploy/recipes/nuxt'
import '@catapultjs/deploy/recipes/git'
import '@catapultjs/deploy/recipes/redis'
import '@catapultjs/deploy/recipes/pm2'
set('directus_path', 'apps/cms')
set('directus_snapshot_path', './database/snapshot.yaml')
set('nuxt_path', 'apps/web')
set('redis_db', 2)
before('deploy:publish', 'redis:db:flush')
export default defineConfig({
hosts: [
{
name: 'production',
ssh: 'deploy@example.com',
deployPath: '/home/deploy/acme',
branch: 'main',
},
],
})In this setup:
deploy:update_codecomes fromgitdeploy:installis inserted bynuxtanddirectus, and its default implementation already runs at the monorepo root ()deploy:buildcomes fromnuxtand runs inapps/webdirectus:database:migratecomes fromdirectusand runs inapps/cmsbefore publishredis:db:flushis added manually beforedeploy:publishto clear Nuxt route cache in Redis database 2
Generated pipeline:
text
deploy:lock
git:check
deploy:release
git:update
deploy:update_code
deploy:install
deploy:shared
deploy:build
directus:database:migrate
directus:snapshot:apply
redis:db:flush
deploy:publish
pm2:startOrReload
pm2:save
deploy:log_revision
deploy:unlock
deploy:cleanupTips
- Keep the transfer step simple:
gitfor full-repository deploys,rsyncorastrofor artifact deploys - Override
deploy:installonly when the default install step is not enough, for example if the monorepo needs a custom install command - Override
deploy:buildwhen the app build command differs from a single-package repository - Use
shared_dirsandshared_filesexactly the same way as in a non-monorepo project