Skip to content
lorebow

Codebase

One app lives in one repository, and every environment runs a build of that same code.

KFounder and editor 180 words 1 min read Find it on the map
On this page

One codebase, tracked in version control, deployed many times. The codebase is the repository: every commit that makes up the app. A deploy is one running copy of the app, like production, staging or the one on your laptop.

One repo, many deploysStep 1 of 3
Repoacme/shopLaptopcommit f3a9Stagingcommit c71eProductioncommit 8b20

1.One repository

All of the app's code lives in one git repository. Nothing it needs is copied in by hand.

#The two ways to break it

Several apps in one repo. If the shop and the admin panel live in one repository, that's not one app: it's a distributed system, and each part should be its own app with its own codebase. A monorepo can still work, as long as each app inside it builds and deploys on its own.

One app in several repos. If deploying the app means pulling three repositories together, those repos are really one codebase split in pieces. Merge them, or turn the shared parts into libraries.

#Share code through libraries

When two apps need the same code, don't copy it and don't share a repository. Publish it as a package, and let each app declare it as a dependency.

Before and aftertext
shop/            ← one repo, two apps (breaks the rule)
  storefront/
  admin/
  common/
 
shop-storefront/   ← own repo, depends on acme-common
shop-admin/        ← own repo, depends on acme-common
acme-common/       ← a library, published as a package
Production and staging run different commits of the same repo. Is that a problem?

Referenced by