> ## Documentation Index
> Fetch the complete documentation index at: https://inframan.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Builds

> How Inframan builds your images from a Dockerfile, where builds run, and how unchanged services skip the build entirely.

Inframan builds a container image for each service from its `Dockerfile`, on your infrastructure, and pushes it to your infrastructure's registry: Artifact Registry on Google Cloud or Amazon ECR on AWS.

## What you need

* A `Dockerfile` for each service. Inframan builds only from Dockerfiles.
* `path` and `build.dockerfile` in [`inframan.yaml`](https://inframan.mintlify.site/deploy/inframan-yaml#build), if the defaults don't fit. `path` is the build context, and `dockerfile` is relative to it.

Images are built for `linux/amd64`.

## Where builds run

You choose when you [create the infrastructure](https://inframan.mintlify.site/provision/create-infrastructure.md):

| Option | How it works | Clouds |
| - | - | - |
| **In this infrastructure** (default) | Each build is a Kubernetes Job on the infrastructure's own build node pool, apart from the pools that serve traffic. The pool keeps one warm node by default, so builds start without waiting for a node. | Google Cloud, AWS |
| **Builder machines** | Each build runs on a short-lived build machine in your project, created for the build and removed after it. One machine is kept warm by default. | Google Cloud |

A build is stopped if it runs for longer than 30 minutes.

## Builds that don't need to happen

Inframan skips work that wouldn't change anything:

* **Already built:** if this commit was already built for the service, its image is reused.
* **Nothing changed:** if none of the service's `watch_paths`, or nothing in its build context, changed since its last image, the image is reused. In a monorepo this means a push that touches one service rebuilds only that service.
* **Shared builds:** services with an identical build, the same context, Dockerfile and build arguments, are built once and share the image.

When a build does run, Docker's layer cache is kept in your registry, so unchanged layers aren't rebuilt.

```yaml inframan.yaml theme={null}
services:
  api:
    port: 8080
    build:
      dockerfile: services/api/Dockerfile
      watch_paths: [services/api, packages/shared]
```

## Build arguments and secrets

* Every plain variable from the service's `env` and its env groups is passed to the build as a `--build-arg`. Declare it with `ARG` in your `Dockerfile` to use it.
* Secrets marked for builds are mounted with BuildKit's secret mount, so they never end up in an image layer. See [Secrets at build time](https://inframan.mintlify.site/deploy/environment-variables.md#secrets-at-build-time).

> [!WARNING]
>
> Because plain variables become build arguments, don't put anything sensitive in `env`. Build arguments can be read from an image's history. Use [secrets](https://inframan.mintlify.site/deploy/environment-variables.md#secrets).

## How your code is fetched

Inframan clones the pushed commit's branch with a shallow, single-branch clone. Git submodules and Git LFS files aren't fetched, so vendor what the build needs or fetch it in your `Dockerfile`.

## Before the build

To run tests or linters before an image is built, add `pre_build` steps to a [pipeline](https://inframan.mintlify.site/deploy/pipelines.md). A failed step stops the release before anything is built.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.