# `jadpo build`

Build the app to deploy.

Check the project as `jadpo check` does, then compile each deployable into one native binary in build/target/<deployable>/, beside the OpenAPI documents of the APIs it serves and the failure texts their clients show. A binary reads its settings from the environment as it starts, refuses to start against a database that hasn't applied every migration, listens on PORT (8080 when unset), and drains on SIGTERM. Every event it logs carries its build stamp: the build id, the commit, whether the tree had changes, the compiler, the deployable and the target. `deployables:` in app.jadpo names each one, what it serves and runs and its target; with none declared there is one, `app`, which runs everything. One built for Target.wasm becomes a WebAssembly module for Cloudflare Workers instead, beside Jadpo's module shim and a wrangler.json naming the settings it needs, its size shown raw and gzipped; the Worker reads its settings from its bindings and serves once its database has every migration. It compiles offline in release with the toolchain and the runtime's lock this Jadpo was built with, keeping each one's Rust in build/rust/<deployable>/.

```text
jadpo build [deployable]
```

## Arguments

- `deployable` (optional): The deployable to build; every one when left out

## On every command

- `--json`: Print data for tools instead of text
- `--help`: Show every flag, with examples
- `--color <when>`: Choose when to use colour

`jadpo build --json` writes one JSON document to standard output instead of text, with the same exit code. The document has `schemaVersion`, `command` (`"build"`), `ok`, `data` (what the command produced, `null` when it failed) and `diagnostics` (each error with its `rule`, `reason`, `next` and `help`). A command that needs a terminal refuses `--json` and names the flags that do the same job.

## Examples

```text
# Build every deployable of the app you are in
jadpo build
# Build one deployable
jadpo build kiosk
# Print where it was written and its build stamp as data
jadpo build --json
```

## Errors

- [`cli.build_arguments`](../errors/cli.build_arguments.md): Build command has invalid arguments
- [`toolchain.build_failed`](../errors/toolchain.build_failed.md): Rust compiler couldn't build the deployable
- [`toolchain.fetch_failed`](../errors/toolchain.fetch_failed.md): Rust toolchain or crates couldn't be fetched
- [`toolchain.artifact_write_failed`](../errors/toolchain.artifact_write_failed.md): Generated file could not be written
- [`toolchain.project_not_found`](../errors/toolchain.project_not_found.md): Project could not be found
