# Builds

Builds define how to produce artifacts. Services reference builds.

```hcl
build "api" {
  base = "node"
  command = "npm run build"
}
```

## Required fields

- `base` - Base environment. Supported: `"node"`, `"python"`, `"go"`, `"rust"`, `"java"`.

## Optional fields

- `command` - Build command to run after dependencies are installed (e.g., `npm run build`, `go build -o api`).

## Automatic dependency installation

Specific automatically installs dependencies before running your build command. Dependencies are cached in a separate Docker layer for faster builds when only source code changes.

| Base | Detected Files | Install Command |
|------|----------------|-----------------|
| `node` | `package-lock.json` | `npm ci` |
| `node` | `yarn.lock` | `yarn install --frozen-lockfile` |
| `node` | `pnpm-lock.yaml` | `pnpm install --frozen-lockfile` |
| `node` | `package.json` only | `npm install` |
| `python` | `requirements.txt` | `pip install -r requirements.txt` |
| `python` | `Pipfile.lock` | `pipenv install --deploy --system` |
| `python` | `poetry.lock` | `poetry install` |
| `python` | `pyproject.toml` | `pip install .` |
| `go` | `go.mod` | `go mod download` |

For simple projects that only need dependencies installed, you can omit the `command` field:

```hcl
build "api" {
  base = "node"
}
```

## Base details

For **node** and **python**, the entire working directory is available at runtime.

For **go**, **rust**, and **java**, a multi-stage build is used:

- **go**: The entire working directory is copied to the runtime image.
- **rust**: Only `target/release` is copied to the working directory in the runtime image.
- **java**: JAR files from `target/*.jar` or `build/libs/*.jar` are copied to `app.jar` in the working directory.

## Dev configuration

Override the build command for local development. If no `dev` block is defined, the build is skipped in development.

```hcl
build "spa" {
  base = "node"
  command = "npm run build"

  dev {
    command = "npm run build:watch"
  }
}
```

---

Run `specific docs services` for service configuration.
