Astro supports a range of options when it comes to organizing your project code. This guide covers the options along with their pros and cons, so you can choose the best option for your team.Documentation Index
Fetch the complete documentation index at: https://astronomer-preview.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Feature overview
Astro supports two 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.
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.
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.