|
| 1 | +--- |
| 2 | +layout: docs |
| 3 | +title: Build API Reference |
| 4 | +--- |
| 5 | + |
| 6 | +# Build |
| 7 | + |
| 8 | +A Build represents a build job in OpenChoreo that transforms source code into a container image. It defines the |
| 9 | +source repository, revision, and build template to use for creating workloads. Upon successful |
| 10 | +completion, a Build creates a Workload resource containing the built container image. |
| 11 | + |
| 12 | +## API Version |
| 13 | + |
| 14 | +`openchoreo.dev/v1alpha1` |
| 15 | + |
| 16 | +## Resource Definition |
| 17 | + |
| 18 | +### Metadata |
| 19 | + |
| 20 | +Builds are namespace-scoped resources that must be created within an Organization's namespace and belong to a |
| 21 | +Component through the owner field. |
| 22 | + |
| 23 | +```yaml |
| 24 | +apiVersion: openchoreo.dev/v1alpha1 |
| 25 | +kind: Build |
| 26 | +metadata: |
| 27 | + name: <build-name> |
| 28 | + namespace: <org-namespace> # Organization namespace |
| 29 | +``` |
| 30 | +
|
| 31 | +### Spec Fields |
| 32 | +
|
| 33 | +| Field | Type | Required | Default | Description | |
| 34 | +|---------------|-----------------------------|----------|---------|--------------------------------------------------------------------| |
| 35 | +| `owner` | [BuildOwner](#buildowner) | Yes | - | Ownership information linking the build to a project and component | |
| 36 | +| `repository` | [Repository](#repository) | Yes | - | Source repository configuration | |
| 37 | +| `templateRef` | [TemplateRef](#templateref) | Yes | - | Build template reference and parameters | |
| 38 | + |
| 39 | +### BuildOwner |
| 40 | + |
| 41 | +| Field | Type | Required | Default | Description | |
| 42 | +|-----------------|--------|----------|---------|-----------------------------------------------------| |
| 43 | +| `projectName` | string | Yes | - | Name of the project that owns this build (min: 1) | |
| 44 | +| `componentName` | string | Yes | - | Name of the component that owns this build (min: 1) | |
| 45 | + |
| 46 | +### Repository |
| 47 | + |
| 48 | +| Field | Type | Required | Default | Description | |
| 49 | +|------------|-----------------------|----------|---------|--------------------------------------------------------------------| |
| 50 | +| `url` | string | Yes | - | Repository URL (e.g., https://github.com/org/repo) | |
| 51 | +| `revision` | [Revision](#revision) | Yes | - | Revision specification for the build | |
| 52 | +| `appPath` | string | Yes | - | Path to the application within the repository (e.g., "." for root) | |
| 53 | + |
| 54 | +### Revision |
| 55 | + |
| 56 | +| Field | Type | Required | Default | Description | |
| 57 | +|----------|--------|----------|---------|-------------------------------------------------------------------| |
| 58 | +| `branch` | string | No | "" | Branch to build from | |
| 59 | +| `commit` | string | No | "" | Specific commit hash to build from (takes precedence over branch) | |
| 60 | + |
| 61 | +### TemplateRef |
| 62 | + |
| 63 | +| Field | Type | Required | Default | Description | |
| 64 | +|--------------|---------------------------|----------|---------|------------------------------------------------------| |
| 65 | +| `engine` | string | No | "" | Build engine to use | |
| 66 | +| `name` | string | Yes | - | Name of the build template (ClusterWorkflowTemplate) | |
| 67 | +| `parameters` | [[Parameter](#parameter)] | No | [] | Template parameters | |
| 68 | + |
| 69 | +### Parameter |
| 70 | + |
| 71 | +| Field | Type | Required | Default | Description | |
| 72 | +|---------|--------|----------|---------|-----------------| |
| 73 | +| `name` | string | Yes | - | Parameter name | |
| 74 | +| `value` | string | Yes | - | Parameter value | |
| 75 | + |
| 76 | +### Status Fields |
| 77 | + |
| 78 | +| Field | Type | Default | Description | |
| 79 | +|---------------|-----------------|---------|---------------------------------------------------------| |
| 80 | +| `conditions` | []Condition | [] | Standard Kubernetes conditions tracking the build state | |
| 81 | +| `imageStatus` | [Image](#image) | {} | Information about the built image | |
| 82 | + |
| 83 | +### Image |
| 84 | + |
| 85 | +| Field | Type | Default | Description | |
| 86 | +|---------|--------|---------|-----------------------------------------------------------| |
| 87 | +| `image` | string | "" | Full image reference including registry, name, and digest | |
| 88 | + |
| 89 | +#### Condition Types |
| 90 | + |
| 91 | +Common condition types for Build resources: |
| 92 | + |
| 93 | +- `Ready` - Indicates if the build has completed successfully |
| 94 | +- `Building` - Indicates if the build is currently in progress |
| 95 | +- `Failed` - Indicates if the build has failed |
| 96 | + |
| 97 | +## Examples |
| 98 | + |
| 99 | +### Build with Docker Template |
| 100 | + |
| 101 | +```yaml |
| 102 | +apiVersion: openchoreo.dev/v1alpha1 |
| 103 | +kind: Build |
| 104 | +metadata: |
| 105 | + name: customer-service-build-abc123 |
| 106 | + namespace: default |
| 107 | +spec: |
| 108 | + owner: |
| 109 | + projectName: my-project |
| 110 | + componentName: customer-service |
| 111 | + repository: |
| 112 | + url: https://github.com/myorg/customer-service |
| 113 | + revision: |
| 114 | + branch: main |
| 115 | + commit: abc123def456 |
| 116 | + appPath: . |
| 117 | + templateRef: |
| 118 | + name: docker |
| 119 | + parameters: |
| 120 | + - name: docker-context |
| 121 | + value: . |
| 122 | + - name: dockerfile-path |
| 123 | + value: ./Dockerfile |
| 124 | +``` |
| 125 | + |
| 126 | +### Build with Buildpacks |
| 127 | + |
| 128 | +```yaml |
| 129 | +apiVersion: openchoreo.dev/v1alpha1 |
| 130 | +kind: Build |
| 131 | +metadata: |
| 132 | + name: frontend-build-xyz789 |
| 133 | + namespace: default |
| 134 | +spec: |
| 135 | + owner: |
| 136 | + projectName: my-project |
| 137 | + componentName: frontend-app |
| 138 | + repository: |
| 139 | + url: https://github.com/myorg/frontend |
| 140 | + revision: |
| 141 | + branch: develop |
| 142 | + appPath: ./webapp |
| 143 | + templateRef: |
| 144 | + name: google-cloud-buildpacks |
| 145 | +``` |
| 146 | + |
| 147 | +## Annotations |
| 148 | + |
| 149 | +Builds support the following annotations: |
| 150 | + |
| 151 | +| Annotation | Description | |
| 152 | +|-------------------------------|------------------------------------| |
| 153 | +| `openchoreo.dev/display-name` | Human-readable name for UI display | |
| 154 | +| `openchoreo.dev/description` | Detailed description of the build | |
| 155 | + |
| 156 | +## Related Resources |
| 157 | + |
| 158 | +- [Component](/docs/reference/api/application/component/) - Components that trigger builds |
| 159 | +- [Workload](/docs/reference/api/application/workload/) - Workloads created by successful builds |
| 160 | +- [BuildPlane](/docs/reference/api/platform/buildplane/) - Infrastructure where builds execute |
0 commit comments