Skip to content

Commit 9bd1325

Browse files
fix: Add local scripts (#6)
Co-authored-by: Nick <10092581+NickLarsenNZ@users.noreply.github.com>
1 parent 6dd4ab5 commit 9bd1325

File tree

13 files changed

+299
-269
lines changed

13 files changed

+299
-269
lines changed

.scripts/get_manifest_digest.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env bash
2+
3+
# Get a manifest digest. Example inputs:
4+
# - docker.stackable.tech/stackable/hello-world:0.0.1-SNAPSHOT-stackable0.0.0-dev
5+
# - docker.stackable.tech/stackable/hello-world:0.0.1-SNAPSHOT-stackable0.0.0-dev-amd64
6+
set -euo pipefail
7+
8+
# Note: `docker manifest push` currently outputs the same hash, but `manifest`
9+
# is experimental and the STDOUT is more likely to change than the structured
10+
# output.
11+
docker buildx imagetools inspect --format '{{println .Manifest.Digest}}' "$1"

README.md

Lines changed: 8 additions & 260 deletions
Original file line numberDiff line numberDiff line change
@@ -17,263 +17,11 @@ particular step in a workflow.
1717
| Image Repo Digest | `docker.stackable.tech/stackable/kafka@sha256:917f800259ef4915f976...` |
1818
| Digest | `sha256:917f800259ef4915f976e93987b752fd64debf347568610d7f685d2022...` |
1919

20-
## `build-container-image`
21-
22-
> Manifest: [build-container-image/action.yml][build-container-image]
23-
24-
This action builds a *single* container image using `docker buildx build`. It does the following work:
25-
26-
1. Free disk space to avoid running out of disk space during larger builds.
27-
2. Build the image using `docker buildx build`, outputting the architecture specific tag.
28-
29-
This action is considered to be the **single** source of truth regarding the image manifest tag.
30-
All subsequent tasks must use this value to ensure consistency.
31-
32-
### Inputs and Outputs
33-
34-
> [!TIP]
35-
> For descriptions of the inputs and outputs, see the complete [build-container-image] action.
36-
37-
#### Inputs
38-
39-
- `image-name` (eg: `kafka`)
40-
- `image-index-manifest-tag` (eg: `3.4.1-stackable0.0.0-dev`)
41-
- `container-file` (defaults to `Dockerfile`)
42-
- `build-context` (defaults to `.`)
43-
<!--
44-
TODO (@NickLarsenNZ): Allow optional buildx cache
45-
- `build-cache-username`
46-
- `build-cache-password`
47-
-->
48-
49-
#### Outputs
50-
51-
- `image-repository-uri` (eg: `localhost/kafka`)
52-
- `image-manifest-tag` (eg: `3.4.1-stackable0.0.0-dev-amd64`)
53-
- `image-manifest-uri` (eg: `localhost/kafka:3.4.1-stackable0.0.0-dev-amd64`)
54-
55-
[build-container-image]: ./build-container-image/action.yml
56-
57-
## `build-product-image`
58-
59-
> Manifest: [build-product-image/action.yml][build-product-image]
60-
61-
<!-- markdownlint-disable-next-line MD028 -->
62-
> [!NOTE]
63-
> The build step is not concerned with registries, ports, paths to repositories, but still requires
64-
> a name. If the name does not contain a registry, `hub.docker.com` (?) is implied. Therefore,
65-
> `localhost` will be used as the registry so as to avoid accidental interactions with an unintended
66-
> registry.
67-
>
68-
> Ideally, bake should be refactored to use `localhost` as the registry for the previously mentioned
69-
> reason (whether or not that is behind some option).
70-
71-
This action builds a *single* container image using `bake`. It does the following work:
72-
73-
1. Free disk space to avoid running out of disk space during larger builds.
74-
2. Build the image using `bake` which internally uses `docker buildx`.
75-
3. Temporarily retag the image to use `localhost` instead of `docker.stackable.tech/stackable`.
76-
4. Produce output values to be used in later steps.
77-
78-
This action is considered to be the **single** source of truth regarding image index tag and image
79-
manifest tag. All subsequent tasks must use these values to ensure consistency.
80-
81-
Currently, bake provides the following ouput in the `bake-target-tags` file:
82-
83-
```plain
84-
docker.stackable.tech/stackable/kafka:3.4.1-stackable0.0.0-dev-amd64
85-
```
86-
87-
Until bake supports the ability to specify the registry, this action will retag the image as:
88-
89-
```plain
90-
localhost/kafka:3.4.1-stackable0.0.0-dev-amd64
91-
```
92-
93-
### Inputs and Outputs
94-
95-
> [!TIP]
96-
> For descriptions of the inputs and outputs, see the complete [build-product-image] action.
97-
98-
#### Inputs
99-
100-
- `product-name`
101-
- `product-version`
102-
- `image-tools-version`
103-
- `build-cache-username`
104-
- `build-cache-password`
105-
106-
#### Outputs
107-
108-
- `image-manifest-tag`
109-
110-
[build-product-image]: ./build-product-image/action.yml
111-
112-
## `publish-image`
113-
114-
> Manifest: [publish-image/action.yml][publish-image]
115-
116-
This action signs and publishes a *single* container image to the given registry. It does the
117-
following work:
118-
119-
1. Tag the `source-image-uri` with the specified `image-registry-uti`, `image-repository`, and
120-
`image-repository`.
121-
2. Push the container image to the specified registry.
122-
3. Sign the container image (which pushes the signature to the specified registry).
123-
4. Generate an SBOM via a syft scan.
124-
5. Attest an image with the SBOM as a predicate (which pushes the attestation to the specified
125-
registry).
126-
127-
### Inputs and Outputs
128-
129-
> [!TIP]
130-
> For descriptions of the inputs and outputs, see the complete [publish-image] action.
131-
132-
<!-- markdownlint-disable-next-line MD028 -->
133-
> [!IMPORTANT]
134-
> For multi-arch images, the `image-manifest-tag` should have the `-$ARCH` suffix, as the tag
135-
> without it should be reserved for the image index manifest which will refer to container images
136-
> for each architecture we will push images for.
137-
138-
#### Inputs
139-
140-
- `image-registry-uri`
141-
- `image-registry-username`
142-
- `image-registry-password`
143-
- `image-repository`
144-
- `image-manifest-tag`
145-
- `source-image-uri`
146-
147-
#### Outputs
148-
149-
None
150-
151-
[publish-image]: ./publish-image/action.yml
152-
153-
## `publish-index-manifest`
154-
155-
> Manifest: [publish-index-manifest/action.yml][publish-index-manifest]
156-
157-
This action creates an image index manifest, publishes it, and signs it. It does the following work:
158-
159-
1. Create an image index manifest and link to each architecture in `image-architectures`.
160-
2. Push the image index manifest.
161-
3. Sign the image index manifest (which pushes the signature to the specified registry).
162-
163-
### Inputs and Outputs
164-
165-
> [!TIP]
166-
> For descriptions of the inputs and outputs, see the complete [publish-index-manifest] action.
167-
168-
#### Inputs
169-
170-
- `image-registry-uri`
171-
- `image-registry-username`
172-
- `image-registry-password`
173-
- `image-repository`
174-
- `image-index-manifest-tag`
175-
- `image-architectures`
176-
177-
#### Outputs
178-
179-
None
180-
181-
[publish-index-manifest]: ./publish-index-manifest/action.yml
182-
183-
## `run-pre-commit`
184-
185-
> Manifest: [run-pre-commit/action.yml][run-pre-commit]
186-
187-
This action runs pre-commit by setting up Python and optionally the Rust toolchain and Hadolint in
188-
the requested version. It requires a checkout with depth 0. It does the following work:
189-
190-
1. Installs Python. The version can be configured via the `python-version` input.
191-
2. Optionally sets up the Rust toolchain and Hadolint.
192-
3. Runs pre-commit on changed files.
193-
194-
Example usage (workflow):
195-
196-
```yaml
197-
---
198-
name: pre-commit
199-
200-
on:
201-
pull_request:
202-
203-
jobs:
204-
pre-commit:
205-
runs-on: ubuntu-latest
206-
steps:
207-
- uses: actions/checkout
208-
with:
209-
fetch-depth: 0
210-
submodules: recursive
211-
- uses: stackabletech/actions/run-pre-commit
212-
```
213-
214-
### Inputs and Outputs
215-
216-
> [!TIP]
217-
> For descriptions of the inputs and outputs, see the complete [run-pre-commit] action.
218-
219-
#### Inputs
220-
221-
- `python-version`
222-
- `rust`
223-
- `rust-components`
224-
- `hadolint`
225-
226-
#### Outputs
227-
228-
None
229-
230-
[run-pre-commit]: ./run-pre-commit/action.yml
231-
232-
## `shard`
233-
234-
> Manifest: [shard/action.yml][shard]
235-
236-
This action produces a list of versions for a product. This is to be used as a matrix dimension to
237-
parallelize builds. It does the following work:
238-
239-
1. Reads the `conf.py`, filtering versions for the product
240-
2. Write the JSON array of version to `$GITHUB_OUTPUT` for use in a matrix.
241-
242-
Example usage:
243-
244-
```yaml
245-
jobs:
246-
generate_matrix:
247-
name: Generate Version List
248-
runs-on: ubuntu-latest
249-
steps:
250-
- uses: actions/checkout
251-
- id: shard
252-
uses: stackabletech/actions/shard
253-
with:
254-
product-name: ${{ env.PRODUCT_NAME }}
255-
outputs:
256-
versions: ${{ steps.shard.outputs.versions }}
257-
258-
actual_matrix:
259-
needs: [generate_matrix]
260-
strategy:
261-
matrix:
262-
versions: ${{ fromJson(needs.generate_matrix.outputs.versions) }}
263-
# ...
264-
```
265-
266-
### Inputs and Outputs
267-
268-
> [!TIP]
269-
> For descriptions of the inputs and outputs, see the complete [shard] action.
270-
271-
#### Inputs
272-
273-
- `product-name`
274-
275-
#### Outputs
276-
277-
- `versions`
278-
279-
[shard]: ./publish-index-manifest/action.yml
20+
## Available Actions
21+
22+
- [build-container-image](./build-container-image/README.md)
23+
- [build-product-image](./build-product-image/README.md)
24+
- [publish-image](./publish-image/README.md)
25+
- [publish-index-manifest](./publish-index-manifest/README.md)
26+
- [run-pre-commit](./run-pre-commit/README.md)
27+
- [shard](./shard/README.md)

build-container-image/README.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# `build-container-image`
2+
3+
> Manifest: [build-container-image/action.yml][build-container-image]
4+
5+
This action builds a *single* container image using `docker buildx build`. It does the following work:
6+
7+
1. Free disk space to avoid running out of disk space during larger builds.
8+
2. Build the image using `docker buildx build`, outputting the architecture specific tag.
9+
10+
This action is considered to be the **single** source of truth regarding the image manifest tag.
11+
All subsequent tasks must use this value to ensure consistency.
12+
13+
## Inputs and Outputs
14+
15+
> [!TIP]
16+
> For descriptions of the inputs and outputs, see the complete [build-container-image] action.
17+
18+
### Inputs
19+
20+
- `image-name` (eg: `kafka`)
21+
- `image-index-manifest-tag` (eg: `3.4.1-stackable0.0.0-dev`)
22+
- `container-file` (defaults to `Dockerfile`)
23+
- `build-context` (defaults to `.`)
24+
<!--
25+
TODO (@NickLarsenNZ): Allow optional buildx cache
26+
- `build-cache-username`
27+
- `build-cache-password`
28+
-->
29+
30+
### Outputs
31+
32+
- `image-repository-uri` (eg: `localhost/kafka`)
33+
- `image-manifest-tag` (eg: `3.4.1-stackable0.0.0-dev-amd64`)
34+
- `image-manifest-uri` (eg: `localhost/kafka:3.4.1-stackable0.0.0-dev-amd64`)
35+
36+
[build-container-image]: ./action.yml

build-container-image/action.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,13 @@ runs:
8585
echo "IMAGE_ARCH=${IMAGE_ARCH}" | tee -a "$GITHUB_ENV"
8686
8787
IMAGE_MANIFEST_TAG="${IMAGE_INDEX_MANIFEST_TAG}-${IMAGE_ARCH}"
88-
echo "IMAGE_MANIFEST_TAG=${IMAGE_MANIFEST_TAG}" | tee -a $GITHUB_OUTPUT
88+
echo "IMAGE_MANIFEST_TAG=${IMAGE_MANIFEST_TAG}" | tee -a "$GITHUB_OUTPUT"
8989
9090
IMAGE_REPOSITORY_URI="localhost/${IMAGE_NAME}"
91-
echo "IMAGE_REPOSITORY_URI=${IMAGE_REPOSITORY_URI}" | tee -a $GITHUB_OUTPUT
91+
echo "IMAGE_REPOSITORY_URI=${IMAGE_REPOSITORY_URI}" | tee -a "$GITHUB_OUTPUT"
9292
9393
IMAGE_MANIFEST_URI="${IMAGE_REPOSITORY_URI}:${IMAGE_MANIFEST_TAG}"
94-
echo "IMAGE_MANIFEST_URI=${IMAGE_MANIFEST_URI}" | tee -a $GITHUB_OUTPUT
94+
echo "IMAGE_MANIFEST_URI=${IMAGE_MANIFEST_URI}" | tee -a "$GITHUB_OUTPUT"
9595
9696
echo "::group::docker buildx build"
9797
# TODO (@NickLarsenNZ): Allow optional buildx cache

build-product-image/README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# `build-product-image`
2+
3+
> Manifest: [build-product-image/action.yml][build-product-image]
4+
5+
<!-- markdownlint-disable-next-line MD028 -->
6+
> [!NOTE]
7+
> The build step is not concerned with registries, ports, paths to repositories, but still requires
8+
> a name. If the name does not contain a registry, `hub.docker.com` (?) is implied. Therefore,
9+
> `localhost` will be used as the registry so as to avoid accidental interactions with an unintended
10+
> registry.
11+
>
12+
> Ideally, bake should be refactored to use `localhost` as the registry for the previously mentioned
13+
> reason (whether or not that is behind some option).
14+
15+
This action builds a *single* container image using `bake`. It does the following work:
16+
17+
1. Free disk space to avoid running out of disk space during larger builds.
18+
2. Build the image using `bake` which internally uses `docker buildx`.
19+
3. Temporarily retag the image to use `localhost` instead of `docker.stackable.tech/stackable`.
20+
4. Produce output values to be used in later steps.
21+
22+
This action is considered to be the **single** source of truth regarding image index tag and image
23+
manifest tag. All subsequent tasks must use these values to ensure consistency.
24+
25+
Currently, bake provides the following ouput in the `bake-target-tags` file:
26+
27+
```plain
28+
docker.stackable.tech/stackable/kafka:3.4.1-stackable0.0.0-dev-amd64
29+
```
30+
31+
Until bake supports the ability to specify the registry, this action will retag the image as:
32+
33+
```plain
34+
localhost/kafka:3.4.1-stackable0.0.0-dev-amd64
35+
```
36+
37+
## Inputs and Outputs
38+
39+
> [!TIP]
40+
> For descriptions of the inputs and outputs, see the complete [build-product-image] action.
41+
42+
### Inputs
43+
44+
- `product-name` (eg: `kafka`)
45+
- `product-version` (eg: `3.4.1`)
46+
- `image-tools-version` (eg: `0.0.13`)
47+
- `build-cache-username` (required) <!-- TODO: make the cache optional -->
48+
- `build-cache-password` (required) <!-- TODO: make the cache optional -->
49+
50+
### Outputs
51+
52+
- `image-manifest-tag` (eg: `3.4.1-stackable0.0.0-dev-amd64`)
53+
54+
[build-product-image]: ./action.yml

build-product-image/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,4 +113,4 @@ runs:
113113
114114
# Add the contents of the env variables to the GitHub output, so that it
115115
# can be used as action outputs
116-
echo "IMAGE_MANIFEST_TAG=$IMAGE_MANIFEST_TAG" >> $GITHUB_OUTPUT
116+
echo "IMAGE_MANIFEST_TAG=$IMAGE_MANIFEST_TAG" | tee -a "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)