# `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
- `--full`: Show everything a report shortens
- `--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`](/docs/errors/cli.build_arguments.md): A `jadpo build` command names a deployable the app doesn't have, or more than one
- [`toolchain.build_failed`](/docs/errors/toolchain.build_failed.md): The Rust `jadpo build` wrote for a deployable didn't compile, because the machine lacks something the build runs, such as a C compiler, or because of a mistake in Jadpo
- [`toolchain.fetch_failed`](/docs/errors/toolchain.fetch_failed.md): The Rust toolchain or the crates `jadpo build` compiles with couldn't be fetched, usually because the server they come from, or the mirror in its place, can't be reached
- [`toolchain.artifact_write_failed`](/docs/errors/toolchain.artifact_write_failed.md): A file Jadpo writes for you, such as a record, couldn't be written, usually because it or its folder is read-only
- [`toolchain.project_not_found`](/docs/errors/toolchain.project_not_found.md): You ran a command that works on a project in a folder with no `app.jadpo`, in it or in any folder above it
