# How builds work

Source: https://openpanel.sh/docs/builds

A service from Git is built on your own server, with its Dockerfile or with Railpack, by OpenPanel's agent there.

When you deploy a service that comes from a [Git repository](/docs/deploy/git), it is built into an image on one of your own servers. OpenPanel's servers never see your code.

Everything here works the same from the console, the [CLI](/docs/cli), the [API](/docs/api) and [MCP](/docs/ai). In the console, a service's build is set under **Build and start**, in **New service** and on the service's **Settings** tab: **Auto** builds with Railpack, **Dockerfile** with the path you give.

## Where a build runs [#where-a-build-runs]

- **On your server.** The build runs on the first server the deployment is placed on, by OpenPanel's [agent](/docs/servers/agent) there, with the server's own `git` and Docker's `buildx`. The agent's installer adds both when they are missing.
- **One at a time.** A server runs one build at a time; the next waits for it.
- **With the server's resources.** A build is not limited: it uses the server's processors and memory, beside the services that run there.
- **In a folder of its own.** Each build clones into a scratch folder that is deleted when the build ends, and runs with no Git or Docker settings of the server's own.

## Railpack or a Dockerfile [#railpack-or-a-dockerfile]

| Build | When | What it does |
|---|---|---|
| **Railpack** | The default, when the service names no Dockerfile | Railpack looks at the service's folder, works out its language and framework, and builds an image without a Dockerfile. See [Languages and frameworks](/docs/builds/languages). |
| **Dockerfile** | When you name a Dockerfile | Docker builds the folder with your Dockerfile. See [Dockerfile builds](/docs/builds/dockerfile). |

A repository that has a Dockerfile is still built with Railpack until you name the Dockerfile in the service's settings.

## What a build does, step by step [#what-a-build-does-step-by-step]

1. **Clone.** The agent clones the branch's newest commit, or the commit you deployed, and records the commit it got. A commit that differs from the one you asked for fails the build.
2. **Build.** It builds the service's folder in the repository with Railpack or your Dockerfile.
3. **Keep the image.** The image stays on that server, under a name made of the service's and the deployment's ids, and the deployment moves to `deploying`.
4. **Clean up.** The scratch folder, with the clone and any Git credentials, is deleted.

A path that leads out of the repository, through `..` or a symbolic link, fails the build. The build cannot read the server's own files.

## Variables do not reach the build [#variables-do-not-reach-the-build]

Your service's [variables](/docs/variables) are given to its containers when they run, not to the build. A framework that reads a variable while it builds, for example to put an address into a web page, does not get it. Keep such values in the repository, or read them when the service starts.

## Time limits [#time-limits]

| Limit | What happens |
|---|---|
| **30 minutes** of building | The build stops, and the deployment fails with a message that starts with "The build failed: timed out after 30m0s". |
| **60 minutes** from the deploy | A build that has not finished, for example because the server's agent is offline, fails with "The build did not finish within 60 minutes." |

## Build output [#build-output]

What the build prints is kept with the deployment as its build log (its first 2 MiB, and the last 200 lines of a longer one):

```sh
openpanel logs --deployment "$DEPLOYMENT_ID" --follow
```

or `GET /deployments/{id}/logs` (the MCP tool `deployments_logs`). See [Build and deploy logs](/docs/monitoring/build-logs).

<Cards>
<Card href="/docs/builds/dockerfile" title="Dockerfile builds" description="Name a Dockerfile and its build context." />

<Card href="/docs/builds/languages" title="Languages and frameworks" description="What Railpack builds without a Dockerfile." />

<Card href="/docs/builds/cache" title="Build cache and images" description="What each server keeps between builds." />

<Card href="/docs/troubleshooting/build-fails" title="A build fails" description="The messages, and what to do." />
</Cards>