posit-bakery 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- posit_bakery-0.4.0/.gitignore +4 -0
- posit_bakery-0.4.0/LICENSE.md +21 -0
- posit_bakery-0.4.0/PKG-INFO +113 -0
- posit_bakery-0.4.0/README.md +71 -0
- posit_bakery-0.4.0/posit_bakery/__init__.py +1 -0
- posit_bakery-0.4.0/posit_bakery/__main__.py +4 -0
- posit_bakery-0.4.0/posit_bakery/cli/__init__.py +0 -0
- posit_bakery-0.4.0/posit_bakery/cli/build.py +255 -0
- posit_bakery-0.4.0/posit_bakery/cli/ci.py +314 -0
- posit_bakery-0.4.0/posit_bakery/cli/clean.py +209 -0
- posit_bakery-0.4.0/posit_bakery/cli/common.py +130 -0
- posit_bakery-0.4.0/posit_bakery/cli/create.py +391 -0
- posit_bakery-0.4.0/posit_bakery/cli/get.py +200 -0
- posit_bakery-0.4.0/posit_bakery/cli/main.py +103 -0
- posit_bakery-0.4.0/posit_bakery/cli/remove.py +103 -0
- posit_bakery-0.4.0/posit_bakery/cli/run.py +167 -0
- posit_bakery-0.4.0/posit_bakery/cli/update.py +181 -0
- posit_bakery-0.4.0/posit_bakery/cli/version.py +10 -0
- posit_bakery-0.4.0/posit_bakery/config/__init__.py +18 -0
- posit_bakery-0.4.0/posit_bakery/config/config.py +1081 -0
- posit_bakery-0.4.0/posit_bakery/config/dependencies/__init__.py +73 -0
- posit_bakery-0.4.0/posit_bakery/config/dependencies/const.py +38 -0
- posit_bakery-0.4.0/posit_bakery/config/dependencies/dependency.py +94 -0
- posit_bakery-0.4.0/posit_bakery/config/dependencies/positron.py +70 -0
- posit_bakery-0.4.0/posit_bakery/config/dependencies/python.py +64 -0
- posit_bakery-0.4.0/posit_bakery/config/dependencies/quarto.py +94 -0
- posit_bakery-0.4.0/posit_bakery/config/dependencies/r.py +55 -0
- posit_bakery-0.4.0/posit_bakery/config/dependencies/version.py +247 -0
- posit_bakery-0.4.0/posit_bakery/config/image/__init__.py +16 -0
- posit_bakery-0.4.0/posit_bakery/config/image/build_os.py +89 -0
- posit_bakery-0.4.0/posit_bakery/config/image/build_secret.py +44 -0
- posit_bakery-0.4.0/posit_bakery/config/image/dev_version/__init__.py +20 -0
- posit_bakery-0.4.0/posit_bakery/config/image/dev_version/base.py +269 -0
- posit_bakery-0.4.0/posit_bakery/config/image/dev_version/env.py +103 -0
- posit_bakery-0.4.0/posit_bakery/config/image/dev_version/stream.py +104 -0
- posit_bakery-0.4.0/posit_bakery/config/image/image.py +614 -0
- posit_bakery-0.4.0/posit_bakery/config/image/matrix.py +785 -0
- posit_bakery-0.4.0/posit_bakery/config/image/parsed_version.py +158 -0
- posit_bakery-0.4.0/posit_bakery/config/image/posit_product/__init__.py +0 -0
- posit_bakery-0.4.0/posit_bakery/config/image/posit_product/const.py +56 -0
- posit_bakery-0.4.0/posit_bakery/config/image/posit_product/main.py +270 -0
- posit_bakery-0.4.0/posit_bakery/config/image/posit_product/resolvers.py +138 -0
- posit_bakery-0.4.0/posit_bakery/config/image/variant.py +79 -0
- posit_bakery-0.4.0/posit_bakery/config/image/version.py +553 -0
- posit_bakery-0.4.0/posit_bakery/config/image/version_os.py +133 -0
- posit_bakery-0.4.0/posit_bakery/config/registry.py +41 -0
- posit_bakery-0.4.0/posit_bakery/config/repository.py +141 -0
- posit_bakery-0.4.0/posit_bakery/config/shared.py +57 -0
- posit_bakery-0.4.0/posit_bakery/config/tag.py +176 -0
- posit_bakery-0.4.0/posit_bakery/config/templating/__init__.py +17 -0
- posit_bakery-0.4.0/posit_bakery/config/templating/macros/apt.j2 +173 -0
- posit_bakery-0.4.0/posit_bakery/config/templating/macros/dnf.j2 +148 -0
- posit_bakery-0.4.0/posit_bakery/config/templating/macros/goss.j2 +6 -0
- posit_bakery-0.4.0/posit_bakery/config/templating/macros/python.j2 +198 -0
- posit_bakery-0.4.0/posit_bakery/config/templating/macros/quarto.j2 +150 -0
- posit_bakery-0.4.0/posit_bakery/config/templating/macros/r.j2 +181 -0
- posit_bakery-0.4.0/posit_bakery/config/templating/render.py +44 -0
- posit_bakery-0.4.0/posit_bakery/config/templating/templates/Containerfile.jinja2 +36 -0
- posit_bakery-0.4.0/posit_bakery/config/templating/templates/bakery.yaml.jinja2 +20 -0
- posit_bakery-0.4.0/posit_bakery/config/tools/__init__.py +79 -0
- posit_bakery-0.4.0/posit_bakery/config/tools/base.py +17 -0
- posit_bakery-0.4.0/posit_bakery/config/tools/registry.py +38 -0
- posit_bakery-0.4.0/posit_bakery/const.py +37 -0
- posit_bakery-0.4.0/posit_bakery/error.py +185 -0
- posit_bakery-0.4.0/posit_bakery/image/__init__.py +4 -0
- posit_bakery-0.4.0/posit_bakery/image/bake/__init__.py +5 -0
- posit_bakery-0.4.0/posit_bakery/image/bake/bake.py +297 -0
- posit_bakery-0.4.0/posit_bakery/image/image_metadata.py +242 -0
- posit_bakery-0.4.0/posit_bakery/image/image_target.py +693 -0
- posit_bakery-0.4.0/posit_bakery/image/util.py +23 -0
- posit_bakery-0.4.0/posit_bakery/log.py +45 -0
- posit_bakery-0.4.0/posit_bakery/plugins/__init__.py +0 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/__init__.py +0 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/dgoss/__init__.py +261 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/dgoss/command.py +159 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/dgoss/errors.py +39 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/dgoss/options.py +44 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/dgoss/report.py +263 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/dgoss/suite.py +107 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/hadolint/__init__.py +375 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/hadolint/command.py +103 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/hadolint/errors.py +39 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/hadolint/options.py +104 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/hadolint/report.py +177 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/hadolint/suite.py +131 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/oras/__init__.py +169 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/oras/oras.py +297 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/wizcli/__init__.py +367 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/wizcli/command.py +139 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/wizcli/errors.py +58 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/wizcli/options.py +44 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/wizcli/report.py +175 -0
- posit_bakery-0.4.0/posit_bakery/plugins/builtin/wizcli/suite.py +139 -0
- posit_bakery-0.4.0/posit_bakery/plugins/protocol.py +44 -0
- posit_bakery-0.4.0/posit_bakery/plugins/registry.py +69 -0
- posit_bakery-0.4.0/posit_bakery/registry_management/__init__.py +0 -0
- posit_bakery-0.4.0/posit_bakery/registry_management/dockerhub/__init__.py +6 -0
- posit_bakery-0.4.0/posit_bakery/registry_management/dockerhub/api.py +161 -0
- posit_bakery-0.4.0/posit_bakery/registry_management/dockerhub/clean.py +47 -0
- posit_bakery-0.4.0/posit_bakery/registry_management/dockerhub/readme.py +98 -0
- posit_bakery-0.4.0/posit_bakery/registry_management/ghcr/__init__.py +7 -0
- posit_bakery-0.4.0/posit_bakery/registry_management/ghcr/api.py +96 -0
- posit_bakery-0.4.0/posit_bakery/registry_management/ghcr/clean.py +109 -0
- posit_bakery-0.4.0/posit_bakery/registry_management/ghcr/models.py +57 -0
- posit_bakery-0.4.0/posit_bakery/services/__init__.py +1 -0
- posit_bakery-0.4.0/posit_bakery/settings.py +35 -0
- posit_bakery-0.4.0/posit_bakery/util.py +79 -0
- posit_bakery-0.4.0/pyproject.toml +115 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Posit Software, PBC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: posit-bakery
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: CLI for building, testing, and managing multidimensional container images with variant, version, and OS support.
|
|
5
|
+
Project-URL: Homepage, https://posit-dev.github.io/images-shared/
|
|
6
|
+
Project-URL: Documentation, https://posit-dev.github.io/images-shared/
|
|
7
|
+
Project-URL: Repository, https://github.com/posit-dev/images-shared
|
|
8
|
+
Project-URL: Issues, https://github.com/posit-dev/images-shared/issues
|
|
9
|
+
Project-URL: Changelog, https://github.com/posit-dev/images-shared/releases
|
|
10
|
+
Author-email: "Ian H. Pittwood" <ian.pittwood@posit.co>, Ben Schwedler <ben@posit.co>
|
|
11
|
+
Maintainer-email: Posit Container Team <docker@posit.co>
|
|
12
|
+
License-Expression: MIT
|
|
13
|
+
License-File: LICENSE.md
|
|
14
|
+
Keywords: bake,build,buildx,cli,container,docker,image,posit
|
|
15
|
+
Classifier: Development Status :: 4 - Beta
|
|
16
|
+
Classifier: Environment :: Console
|
|
17
|
+
Classifier: Intended Audience :: Developers
|
|
18
|
+
Classifier: Intended Audience :: System Administrators
|
|
19
|
+
Classifier: Operating System :: MacOS
|
|
20
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
21
|
+
Classifier: Programming Language :: Python :: 3
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
27
|
+
Classifier: Topic :: Software Development :: Build Tools
|
|
28
|
+
Classifier: Topic :: System :: Software Distribution
|
|
29
|
+
Requires-Python: >=3.10
|
|
30
|
+
Requires-Dist: gitpython~=3.1.50
|
|
31
|
+
Requires-Dist: jinja2~=3.1.6
|
|
32
|
+
Requires-Dist: packaging<26.0,>=25.0
|
|
33
|
+
Requires-Dist: pydantic[email]<3.0,>=2.0
|
|
34
|
+
Requires-Dist: pygithub<3.0.0,>=2.8.1
|
|
35
|
+
Requires-Dist: python-on-whales<0.80.0,>=0.79.0
|
|
36
|
+
Requires-Dist: requests-cache<2.0.0,>=1.2.1
|
|
37
|
+
Requires-Dist: requests<3.0.0,>=2.32.5
|
|
38
|
+
Requires-Dist: rich~=14.1.0
|
|
39
|
+
Requires-Dist: ruamel-yaml<0.19.0,>=0.18.14
|
|
40
|
+
Requires-Dist: typer~=0.21.1
|
|
41
|
+
Description-Content-Type: text/markdown
|
|
42
|
+
|
|
43
|
+
<p>
|
|
44
|
+
<a href="https://posit.co/">
|
|
45
|
+
<picture>
|
|
46
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.posit.co/platform/containers/logos/Posit-Logos-2024_horiz-reverse-quarto-web.svg">
|
|
47
|
+
<source media="(prefers-color-scheme: light)" srcset="https://cdn.posit.co/platform/containers/logos/Posit-Logos-2024_horiz-full-color-quarto-web.svg">
|
|
48
|
+
<img alt="Posit Logo" src="https://cdn.posit.co/platform/containers/logos/Posit-Logos-2024_horiz-full-color-quarto-web.svg" height="120">
|
|
49
|
+
</picture>
|
|
50
|
+
</a>
|
|
51
|
+
|
|
52
|
+
<a href="https://posit-dev.github.io/images-shared/">
|
|
53
|
+
<img alt="bakery" src="docs/images/bakery-logo.svg" height="180">
|
|
54
|
+
</a>
|
|
55
|
+
</p>
|
|
56
|
+
|
|
57
|
+
# Bakery
|
|
58
|
+
|
|
59
|
+
The [bakery](./posit_bakery/) command line interface (CLI) binds together various [tools](#3rd-party-tools) to manage a matrixed build of container images.
|
|
60
|
+
|
|
61
|
+
## Documentation
|
|
62
|
+
|
|
63
|
+
Full documentation is available at **[posit-dev.github.io/images-shared](https://posit-dev.github.io/images-shared/)**.
|
|
64
|
+
|
|
65
|
+
## Prerequisites
|
|
66
|
+
|
|
67
|
+
* [python](https://docs.astral.sh/uv/guides/install-python/)
|
|
68
|
+
* [uv](https://docs.astral.sh/uv/getting-started/installation/)
|
|
69
|
+
* [docker buildx bake](https://github.com/docker/buildx#installing)
|
|
70
|
+
* [just](https://just.systems/man/en/prerequisites.html)
|
|
71
|
+
|
|
72
|
+
### 3rd Party Tools
|
|
73
|
+
|
|
74
|
+
| Tool | Used By | Purpose |
|
|
75
|
+
|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------|:-------------------------------------------------------------------|
|
|
76
|
+
| [docker buildx bake](https://github.com/docker/buildx#installing) | `bakery build --strategy bake` | Build containers in parallel |
|
|
77
|
+
| [docker](https://github.com/docker/buildx#installing), [podman](https://podman-desktop.io/docs/installation), or [nerdctl](https://github.com/containerd/nerdctl#install) | `bakery build --strategy build` | Build containers in series |
|
|
78
|
+
| [dgoss](https://github.com/goss-org/goss#installation) | `bakery run dgoss` | Test container images for expected content & behavior |
|
|
79
|
+
| [hadolint](https://github.com/hadolint/hadolint#install) | to be implemented | Lint Dockerfile/Containerfile |
|
|
80
|
+
| [openscap](https://static.open-scap.org/) | to be implemented | Scan container images for secure configuration and vulnerabilities |
|
|
81
|
+
| trivy | to be implemented | Scan container images for vulnerabilities |
|
|
82
|
+
| wizcli | to be implemented | Scan container images for vulnerabilities |
|
|
83
|
+
|
|
84
|
+
## Installation
|
|
85
|
+
|
|
86
|
+
Install `bakery` from [PyPI](https://pypi.org/project/posit-bakery/) using `uv tool`:
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
uv tool install posit-bakery
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
To install an unreleased development version directly from GitHub:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
uv tool install 'git+https://github.com/posit-dev/images-shared.git@main#subdirectory=posit-bakery&egg=posit-bakery'
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Examples
|
|
99
|
+
|
|
100
|
+
See the [Bakery Examples](https://github.com/posit-dev/images-examples/tree/main/bakery) repository for step-by-step tutorials on creating and managing container image projects with Bakery.
|
|
101
|
+
|
|
102
|
+
## Development
|
|
103
|
+
|
|
104
|
+
### Development Prerequisites
|
|
105
|
+
|
|
106
|
+
- [just](https://just.systems/man/en/)
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Show all the just recipes
|
|
110
|
+
just
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
- [uv](https://docs.astral.sh/uv/getting-started/installation/)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
<p>
|
|
2
|
+
<a href="https://posit.co/">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://cdn.posit.co/platform/containers/logos/Posit-Logos-2024_horiz-reverse-quarto-web.svg">
|
|
5
|
+
<source media="(prefers-color-scheme: light)" srcset="https://cdn.posit.co/platform/containers/logos/Posit-Logos-2024_horiz-full-color-quarto-web.svg">
|
|
6
|
+
<img alt="Posit Logo" src="https://cdn.posit.co/platform/containers/logos/Posit-Logos-2024_horiz-full-color-quarto-web.svg" height="120">
|
|
7
|
+
</picture>
|
|
8
|
+
</a>
|
|
9
|
+
|
|
10
|
+
<a href="https://posit-dev.github.io/images-shared/">
|
|
11
|
+
<img alt="bakery" src="docs/images/bakery-logo.svg" height="180">
|
|
12
|
+
</a>
|
|
13
|
+
</p>
|
|
14
|
+
|
|
15
|
+
# Bakery
|
|
16
|
+
|
|
17
|
+
The [bakery](./posit_bakery/) command line interface (CLI) binds together various [tools](#3rd-party-tools) to manage a matrixed build of container images.
|
|
18
|
+
|
|
19
|
+
## Documentation
|
|
20
|
+
|
|
21
|
+
Full documentation is available at **[posit-dev.github.io/images-shared](https://posit-dev.github.io/images-shared/)**.
|
|
22
|
+
|
|
23
|
+
## Prerequisites
|
|
24
|
+
|
|
25
|
+
* [python](https://docs.astral.sh/uv/guides/install-python/)
|
|
26
|
+
* [uv](https://docs.astral.sh/uv/getting-started/installation/)
|
|
27
|
+
* [docker buildx bake](https://github.com/docker/buildx#installing)
|
|
28
|
+
* [just](https://just.systems/man/en/prerequisites.html)
|
|
29
|
+
|
|
30
|
+
### 3rd Party Tools
|
|
31
|
+
|
|
32
|
+
| Tool | Used By | Purpose |
|
|
33
|
+
|:--------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:--------------------------------|:-------------------------------------------------------------------|
|
|
34
|
+
| [docker buildx bake](https://github.com/docker/buildx#installing) | `bakery build --strategy bake` | Build containers in parallel |
|
|
35
|
+
| [docker](https://github.com/docker/buildx#installing), [podman](https://podman-desktop.io/docs/installation), or [nerdctl](https://github.com/containerd/nerdctl#install) | `bakery build --strategy build` | Build containers in series |
|
|
36
|
+
| [dgoss](https://github.com/goss-org/goss#installation) | `bakery run dgoss` | Test container images for expected content & behavior |
|
|
37
|
+
| [hadolint](https://github.com/hadolint/hadolint#install) | to be implemented | Lint Dockerfile/Containerfile |
|
|
38
|
+
| [openscap](https://static.open-scap.org/) | to be implemented | Scan container images for secure configuration and vulnerabilities |
|
|
39
|
+
| trivy | to be implemented | Scan container images for vulnerabilities |
|
|
40
|
+
| wizcli | to be implemented | Scan container images for vulnerabilities |
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
Install `bakery` from [PyPI](https://pypi.org/project/posit-bakery/) using `uv tool`:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
uv tool install posit-bakery
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
To install an unreleased development version directly from GitHub:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
uv tool install 'git+https://github.com/posit-dev/images-shared.git@main#subdirectory=posit-bakery&egg=posit-bakery'
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Examples
|
|
57
|
+
|
|
58
|
+
See the [Bakery Examples](https://github.com/posit-dev/images-examples/tree/main/bakery) repository for step-by-step tutorials on creating and managing container image projects with Bakery.
|
|
59
|
+
|
|
60
|
+
## Development
|
|
61
|
+
|
|
62
|
+
### Development Prerequisites
|
|
63
|
+
|
|
64
|
+
- [just](https://just.systems/man/en/)
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
# Show all the just recipes
|
|
68
|
+
just
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- [uv](https://docs.astral.sh/uv/getting-started/installation/)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.0.0"
|
|
File without changes
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import logging
|
|
2
|
+
from enum import Enum
|
|
3
|
+
from pathlib import Path
|
|
4
|
+
from typing import Annotated, Optional
|
|
5
|
+
|
|
6
|
+
import python_on_whales
|
|
7
|
+
import typer
|
|
8
|
+
|
|
9
|
+
from posit_bakery.cli.common import with_verbosity_flags, with_temporary_storage
|
|
10
|
+
from posit_bakery.config import BakeryConfig
|
|
11
|
+
from posit_bakery.config.config import BakeryConfigFilter, BakerySettings
|
|
12
|
+
from posit_bakery.config.image.posit_product.const import ReleaseStreamEnum
|
|
13
|
+
from posit_bakery.const import DevVersionInclusionEnum, MatrixVersionInclusionEnum
|
|
14
|
+
from posit_bakery.error import BakeryBuildErrorGroup, BakeryToolRuntimeError
|
|
15
|
+
from posit_bakery.image import ImageBuildStrategy
|
|
16
|
+
from posit_bakery.log import stderr_console, stdout_console
|
|
17
|
+
from posit_bakery.util import auto_path
|
|
18
|
+
|
|
19
|
+
log = logging.getLogger(__name__)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class RichHelpPanelEnum(str, Enum):
|
|
23
|
+
"""Enum for categorizing options into rich help panels."""
|
|
24
|
+
|
|
25
|
+
BUILD_CONFIGURATION_AND_OUTPUTS = "Build Configuration & Outputs"
|
|
26
|
+
FILTERS = "Filters"
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@with_verbosity_flags
|
|
30
|
+
@with_temporary_storage
|
|
31
|
+
def build(
|
|
32
|
+
context: Annotated[
|
|
33
|
+
Path,
|
|
34
|
+
typer.Option(
|
|
35
|
+
exists=True,
|
|
36
|
+
file_okay=False,
|
|
37
|
+
dir_okay=True,
|
|
38
|
+
readable=True,
|
|
39
|
+
resolve_path=True,
|
|
40
|
+
help="The root path to use. Defaults to the current working directory where invoked.",
|
|
41
|
+
),
|
|
42
|
+
] = auto_path(),
|
|
43
|
+
strategy: Annotated[
|
|
44
|
+
Optional[ImageBuildStrategy],
|
|
45
|
+
typer.Option(
|
|
46
|
+
case_sensitive=False,
|
|
47
|
+
help="The strategy to use when building the image. 'bake' requires Docker Buildkit and builds "
|
|
48
|
+
"images in parallel. 'build' can use generic container builders, such as Podman, and builds "
|
|
49
|
+
"images sequentially.",
|
|
50
|
+
rich_help_panel=RichHelpPanelEnum.BUILD_CONFIGURATION_AND_OUTPUTS,
|
|
51
|
+
),
|
|
52
|
+
] = ImageBuildStrategy.BAKE,
|
|
53
|
+
fail_fast: Annotated[
|
|
54
|
+
Optional[bool],
|
|
55
|
+
typer.Option(
|
|
56
|
+
"--fail-fast",
|
|
57
|
+
help="Terminate builds on the first failure.",
|
|
58
|
+
rich_help_panel=RichHelpPanelEnum.BUILD_CONFIGURATION_AND_OUTPUTS,
|
|
59
|
+
),
|
|
60
|
+
] = False,
|
|
61
|
+
retry: Annotated[
|
|
62
|
+
int,
|
|
63
|
+
typer.Option(
|
|
64
|
+
min=0,
|
|
65
|
+
help="Number of times to retry a failed build.",
|
|
66
|
+
rich_help_panel=RichHelpPanelEnum.BUILD_CONFIGURATION_AND_OUTPUTS,
|
|
67
|
+
),
|
|
68
|
+
] = 0,
|
|
69
|
+
plan: Annotated[
|
|
70
|
+
Optional[bool],
|
|
71
|
+
typer.Option(
|
|
72
|
+
"--plan",
|
|
73
|
+
help="Print the bake plan and exit.",
|
|
74
|
+
rich_help_panel=RichHelpPanelEnum.BUILD_CONFIGURATION_AND_OUTPUTS,
|
|
75
|
+
),
|
|
76
|
+
] = False,
|
|
77
|
+
load: Annotated[
|
|
78
|
+
Optional[bool],
|
|
79
|
+
typer.Option(
|
|
80
|
+
help="Load the image to Docker after building.",
|
|
81
|
+
rich_help_panel=RichHelpPanelEnum.BUILD_CONFIGURATION_AND_OUTPUTS,
|
|
82
|
+
),
|
|
83
|
+
] = True,
|
|
84
|
+
push: Annotated[
|
|
85
|
+
Optional[bool],
|
|
86
|
+
typer.Option(
|
|
87
|
+
help="Push the image to its registry tags after building.",
|
|
88
|
+
rich_help_panel=RichHelpPanelEnum.BUILD_CONFIGURATION_AND_OUTPUTS,
|
|
89
|
+
),
|
|
90
|
+
] = False,
|
|
91
|
+
clean: Annotated[
|
|
92
|
+
Optional[bool],
|
|
93
|
+
typer.Option(
|
|
94
|
+
help="Clean up intermediary and temporary files after building. Disable for debugging.",
|
|
95
|
+
rich_help_panel=RichHelpPanelEnum.BUILD_CONFIGURATION_AND_OUTPUTS,
|
|
96
|
+
),
|
|
97
|
+
] = True,
|
|
98
|
+
metadata_file: Annotated[
|
|
99
|
+
Optional[Path],
|
|
100
|
+
typer.Option(
|
|
101
|
+
writable=True,
|
|
102
|
+
resolve_path=True,
|
|
103
|
+
help="The path to write JSON build metadata to once builds are finished.",
|
|
104
|
+
rich_help_panel="Build Configuration & Outputs",
|
|
105
|
+
),
|
|
106
|
+
] = None,
|
|
107
|
+
pull: Annotated[
|
|
108
|
+
Optional[bool],
|
|
109
|
+
typer.Option(
|
|
110
|
+
help="Always pull the latest version of base images.",
|
|
111
|
+
rich_help_panel=RichHelpPanelEnum.BUILD_CONFIGURATION_AND_OUTPUTS,
|
|
112
|
+
),
|
|
113
|
+
] = False,
|
|
114
|
+
cache: Annotated[
|
|
115
|
+
Optional[bool],
|
|
116
|
+
typer.Option(
|
|
117
|
+
help="Enable layer caching for image builds.",
|
|
118
|
+
rich_help_panel=RichHelpPanelEnum.BUILD_CONFIGURATION_AND_OUTPUTS,
|
|
119
|
+
),
|
|
120
|
+
] = True,
|
|
121
|
+
cache_registry: Annotated[
|
|
122
|
+
Optional[str],
|
|
123
|
+
typer.Option(
|
|
124
|
+
show_default=False,
|
|
125
|
+
help="External registry to use for layer caching.",
|
|
126
|
+
rich_help_panel=RichHelpPanelEnum.BUILD_CONFIGURATION_AND_OUTPUTS,
|
|
127
|
+
),
|
|
128
|
+
] = None,
|
|
129
|
+
temp_registry: Annotated[
|
|
130
|
+
Optional[str],
|
|
131
|
+
typer.Option(
|
|
132
|
+
help="Temporary registry to use for multiplatform split/merge builds.",
|
|
133
|
+
rich_help_panel="Build Configuration & Outputs",
|
|
134
|
+
),
|
|
135
|
+
] = None,
|
|
136
|
+
image_name: Annotated[
|
|
137
|
+
Optional[str],
|
|
138
|
+
typer.Option(
|
|
139
|
+
show_default=False,
|
|
140
|
+
help="The image name or a regex pattern to isolate builds to.",
|
|
141
|
+
rich_help_panel=RichHelpPanelEnum.FILTERS,
|
|
142
|
+
),
|
|
143
|
+
] = None,
|
|
144
|
+
image_version: Annotated[
|
|
145
|
+
Optional[str],
|
|
146
|
+
typer.Option(
|
|
147
|
+
show_default=False,
|
|
148
|
+
help="The image version or version prefix to isolate builds to.",
|
|
149
|
+
rich_help_panel=RichHelpPanelEnum.FILTERS,
|
|
150
|
+
),
|
|
151
|
+
] = None,
|
|
152
|
+
image_variant: Annotated[
|
|
153
|
+
Optional[str],
|
|
154
|
+
typer.Option(
|
|
155
|
+
show_default=False, help="The image type to isolate builds to.", rich_help_panel=RichHelpPanelEnum.FILTERS
|
|
156
|
+
),
|
|
157
|
+
] = None,
|
|
158
|
+
image_os: Annotated[
|
|
159
|
+
Optional[str],
|
|
160
|
+
typer.Option(
|
|
161
|
+
show_default=False,
|
|
162
|
+
help="The image OS name or a regex pattern to isolate builds to.",
|
|
163
|
+
rich_help_panel=RichHelpPanelEnum.FILTERS,
|
|
164
|
+
),
|
|
165
|
+
] = None,
|
|
166
|
+
image_platform: Annotated[
|
|
167
|
+
Optional[list[str]],
|
|
168
|
+
typer.Option(
|
|
169
|
+
show_default=False,
|
|
170
|
+
help="The image platform(s) to isolate builds to, e.g. 'linux/amd64'. "
|
|
171
|
+
"Image build targets incompatible with the given platform(s) will be skipped.",
|
|
172
|
+
rich_help_panel=RichHelpPanelEnum.FILTERS,
|
|
173
|
+
),
|
|
174
|
+
] = None,
|
|
175
|
+
dev_versions: Annotated[
|
|
176
|
+
Optional[DevVersionInclusionEnum],
|
|
177
|
+
typer.Option(
|
|
178
|
+
help="Include or exclude development version builds defined in config.",
|
|
179
|
+
rich_help_panel=RichHelpPanelEnum.FILTERS,
|
|
180
|
+
),
|
|
181
|
+
] = DevVersionInclusionEnum.EXCLUDE,
|
|
182
|
+
dev_stream: Annotated[
|
|
183
|
+
Optional[ReleaseStreamEnum],
|
|
184
|
+
typer.Option(
|
|
185
|
+
help="Filter development versions to a specific release stream.",
|
|
186
|
+
rich_help_panel=RichHelpPanelEnum.FILTERS,
|
|
187
|
+
),
|
|
188
|
+
] = None,
|
|
189
|
+
matrix_versions: Annotated[
|
|
190
|
+
Optional[MatrixVersionInclusionEnum],
|
|
191
|
+
typer.Option(
|
|
192
|
+
help="Include or exclude versions defined in image matrix.",
|
|
193
|
+
rich_help_panel=RichHelpPanelEnum.FILTERS,
|
|
194
|
+
),
|
|
195
|
+
] = MatrixVersionInclusionEnum.EXCLUDE,
|
|
196
|
+
) -> None:
|
|
197
|
+
"""Builds images in the context path
|
|
198
|
+
|
|
199
|
+
If no options are provided, the command will auto-discover all images in the current
|
|
200
|
+
directory and generate a temporary bake plan to execute for all targets.
|
|
201
|
+
|
|
202
|
+
Requires the Docker Engine and CLI to be installed and running for `--strategy bake`.
|
|
203
|
+
|
|
204
|
+
Requires Docker, Podman, or nerdctl to be installed and running for `--strategy build`.
|
|
205
|
+
"""
|
|
206
|
+
settings = BakerySettings(
|
|
207
|
+
filter=BakeryConfigFilter(
|
|
208
|
+
image_name=image_name,
|
|
209
|
+
image_version=image_version,
|
|
210
|
+
image_variant=image_variant,
|
|
211
|
+
image_os=image_os,
|
|
212
|
+
image_platform=image_platform or [],
|
|
213
|
+
),
|
|
214
|
+
dev_versions=dev_versions,
|
|
215
|
+
dev_stream=dev_stream,
|
|
216
|
+
matrix_versions=matrix_versions,
|
|
217
|
+
clean_temporary=clean,
|
|
218
|
+
cache_registry=cache_registry,
|
|
219
|
+
temp_registry=temp_registry,
|
|
220
|
+
)
|
|
221
|
+
config: BakeryConfig = BakeryConfig.from_context(context, settings)
|
|
222
|
+
|
|
223
|
+
if plan:
|
|
224
|
+
if strategy == ImageBuildStrategy.BUILD:
|
|
225
|
+
# TODO: This should turn into dry-run behavior eventually.
|
|
226
|
+
stderr_console.print(
|
|
227
|
+
"❌ The --plan option is not supported with the 'build' strategy. "
|
|
228
|
+
"Please use the 'bake' strategy to print the bake plan.",
|
|
229
|
+
style="error",
|
|
230
|
+
)
|
|
231
|
+
raise typer.Exit(code=1)
|
|
232
|
+
stdout_console.print_json(config.bake_plan_targets(push=push))
|
|
233
|
+
raise typer.Exit(code=0)
|
|
234
|
+
|
|
235
|
+
try:
|
|
236
|
+
config.build_targets(
|
|
237
|
+
load=load,
|
|
238
|
+
push=push,
|
|
239
|
+
pull=pull,
|
|
240
|
+
cache=cache,
|
|
241
|
+
platforms=image_platform,
|
|
242
|
+
strategy=strategy,
|
|
243
|
+
fail_fast=fail_fast,
|
|
244
|
+
retry=retry,
|
|
245
|
+
metadata_file=metadata_file,
|
|
246
|
+
)
|
|
247
|
+
except BakeryBuildErrorGroup as e:
|
|
248
|
+
stderr_console.print(str(e))
|
|
249
|
+
stderr_console.print("❌ Build failed", style="error")
|
|
250
|
+
raise typer.Exit(code=1)
|
|
251
|
+
except (python_on_whales.DockerException, BakeryToolRuntimeError):
|
|
252
|
+
stderr_console.print("❌ Build failed", style="error")
|
|
253
|
+
raise typer.Exit(code=1)
|
|
254
|
+
|
|
255
|
+
stderr_console.print("✅ Build completed", style="success")
|