policy: implement policy support for bake

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
Tonis Tiigi
2026-01-14 09:34:23 -08:00
parent 6f9a1cfb17
commit 9f1daffb32
13 changed files with 605 additions and 117 deletions
+16
View File
@@ -236,6 +236,7 @@ The following table shows the complete list of attributes that you can assign to
| [`no-cache-filter`](#targetno-cache-filter) | List | Disable build cache for specific stages |
| [`no-cache`](#targetno-cache) | Boolean | Disable build cache completely |
| [`output`](#targetoutput) | List | Output destinations |
| [`policy`](#targetpolicy) | List | Policies to validate build sources and metadata |
| [`platforms`](#targetplatforms) | List | Target platforms |
| [`pull`](#targetpull) | Boolean | Always pull images |
| [`secret`](#targetsecret) | List | Secrets to expose to the build |
@@ -899,6 +900,21 @@ target "default" {
}
```
### `target.policy`
Policies to validate build sources and metadata. Each entry uses the same keys
as the `--policy` flag for `docker buildx build` (`filename`, `reset`,
`disabled`, `strict`, `log-level`). Bake also automatically loads
`Dockerfile.rego` alongside the target Dockerfile when present.
```hcl
target "default" {
policy = [
{ filename = "extra.rego" },
]
}
```
### `target.platforms`
Set target platforms for the build target.