> For the complete documentation index, see [llms.txt](https://docs.usegallery.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.usegallery.com/build-system/project-builds/build-stages.md).

# Build Stages

Gallery jobs are grouped into parallelizable stages. There are two types of stages, pre-infra (`init_stages`) and post-infra (`infra_stages`) stages, which have slightly different roles. Define these stages at the top of the `.gallery-deploy.yml` file:

```
init_stages:
    - build
infra_stages:
    - deploy
```

### Pre-Infrastructure Stages

Pre-infrastructure stages can be used to build code that will be used by the infrastructure deployment steps. For example, if you need to deploy a docker image to a managed instance group in a terraform file, you'll need to build the image in the pre-infrastructure stage.

### Post-Infrastructure Stages

Some providers don't have great support for deploying built code directly using terraform, and you may have to deploy artifacts on top of the infrastructure after it is created. You can use post-infrastructure stages to do this -- you'll have access to [environment variable mappers](/build-system/terraform/mapping-urls-configs.md#adding-environment-mappers) in these stages to give you information on the created infrastructure.
