Feature overview
Astro supports three basic repository strategies. You can:- Use a monorepo: host an Astro project in one repository for deploys to one or multiple Astro Deployments, based, for example, on permanent dev and prod branches with their own Deployments or a single permanent branch. Astronomer recommends this approach for most teams.
- Use a multirepo: separate your Dags from other files in your project and maintain multiple repositories linked to one or multiple Astro Deployments. Astronomer recommends this approach for teams needing to meet strict security requirements and teams planning to automate the creation of Deployments.
- Use Dag bundles: let multiple teams each keep their own repository and deploy independently to a single, shared Deployment. Astronomer recommends this approach for multiple teams that want to share a Deployment without sharing a repository.
Best practice guidance
Depending on your organization’s structure and needs, Astronomer recommends either a monorepo or multirepo approach to organizing the code you deploy to Astro. In addition to a repository strategy, Astronomer recommends implementing version control and CI/CD.Option 1: Monorepo
This is the most common strategy.
- One Astro Workspace for your project(s).
- One or more permanent branches in your repository, each representing an environment. Many teams use two permanent branches named
mainanddev. - One or more Astro Deployments, each representing an environment.
- You can test code changes to your Dags in an isolated environment on Astro before deploying the changes to production.
- It is flexible and scalable. Mapping branches to additional Deployments allows for permanent testing environments or ephemeral sandbox Deployments for feature testing. See Manage dev Deployments on Astro. Also, if you work at a larger organization, you can deploy to different Workspaces and Astro projects to support multiple teams or organize Deployments according to specific business use cases.
- It supports separate environment configurations. For example, your development Deployment can query a development database, and your production Deployment can query a production database without needing complex logic to switch between the two.
- Dependencies and environments might be more difficult to manage, to the extent that they differ from project to project.
Individuals and small teams getting started on Astro can keep their instances simple with one permanent branch mapped to an Astro Deployment.
Option 2: Multirepo
A common use case for multiple repositories is keeping Astro Project configuration (such as theDockerfile, requirements.txt, or Deployment Configuration-as-Code) separate from Dag code. Astronomer recommends a multirepo approach when:
- You have strict security requirements for who can manage Deployments.
- You want to minimize complexity for project contributors, automate the creation of Deployments, or manage Deployments more efficiently.
- You can set up and maintain a more complex CI/CD pipeline.
- A Workspace for your project(s).
- Multiple repositories.
- One or more Astro Deployments.
- Dag-only deploys on the target Deployment and CI/CD pipeline setup for each repository.
- Keeping project configuration separate from Dag code enables the use of a single repository for configuring multiple Deployments.
- The possibility of accidental changes to Astro Deployment settings is minimized.
- You can automate the creation of Deployments and streamline your Deployment management process.
- You must keep any local copies of an Astro project synchronized with multiple repositories in order to test Deployment code locally.
- Team members might have inconsistencies in their local environments if they lack access to the configuration repository. For this reason, Astronomer recommends setting up a Dev Deployment where Dag authors can see and modify project configuration for testing purposes.
Option 3: Dag bundles for multiple teams
This requires an Airflow 3 Deployment. See Dag bundles for complete setup steps and requirements.
- Multiple teams want to share the cost and operational overhead of a single Deployment.
- Each team already maintains its own repository and CI/CD pipeline.
- You don’t need to split Dag code from Deployment configuration within a single team’s project. See Option 2: Multirepo for that use case.
- One Astro Workspace for the shared Deployment.
- One repository per team.
- One Airflow 3 Deployment with Dag-only deploys enabled.
- A CI/CD pipeline per repository that deploys to its own bundle, for example
astro deploy --dags --dag-bundle-name finance.
- Teams don’t need access to each other’s repositories or CI/CD pipelines.
- A deploy from one team’s pipeline never overwrites another team’s Dags.
- Teams can be added to or removed from a shared Deployment without migrating code between repositories.
- Fewer Deployments to create and maintain than one Deployment per team, though a shared Deployment needs enough resources for every team’s combined workload.
- Every team’s Dags run in the same Airflow environment, so they must all support the same Airflow, Python, and system package versions.
- Upgrading Airflow or the underlying image requires coordinating with every team on the Deployment.
- One team’s Dags can compete with another team’s for dag processor and worker resources, sometimes called the noisy neighbor problem. Worker queues can isolate compute for specific Dags.
- Dag IDs must be unique across every team’s bundle. See Dag IDs must be unique across bundles.
The Data Platform Engineer’s repository has no
dags directory, so its deploy uses --image to update only the project image without touching any Dag bundle. By default, a new non-Dag bundle is served alongside main; since Dags in finance orchestrate these dbt models with Cosmos, associate the dbt bundle with finance instead.
Version control and CI/CD
In addition to choosing a repository strategy suited to your use case, Astronomer recommends implementing version control and CI/CD. Implementing version control is a longstanding software development best practice that enables:- Simultaneous collaboration.
- Easy review of code changes.
- Safe and secure experimentation on new features and fixes.
- Improved traceability and auditing.
- Faster feedback loops.
- Improved code quality.
- Streamlined development workflows.
- Consistent deployments across environments.
- Less time spent getting code to production.
- Enhanced collaboration.