feat(image): build the ci image next to the molecule image
Matrix over both images. molecule-ubuntu2404 keeps its sub-path context; ci uses the repository root as context (its Dockerfile copies the pin files) and also rebuilds when requirements-dev.txt or .pre-commit-config.yaml change. Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
This commit is contained in:
1 parent
924a598233
commit
98ca27bbc0
1 file changed
+29
-8
@@ -1,7 +1,8 @@
|
|||||||
name: Molecule image
|
name: Molecule image
|
||||||
|
|
||||||
# Builds images/molecule-ubuntu2404 with kaniko (osscontainertools fork, v1.28.6) and
|
# Builds the images under images/ with kaniko (osscontainertools fork, v1.28.6) and
|
||||||
# pushes it to git.rkdr.net/mortis/molecule-ubuntu2404 (ADR 0004, Image distribution).
|
# pushes them to git.rkdr.net/mortis/<name> (ADR 0004, Image distribution): the molecule
|
||||||
|
# test target (molecule-ubuntu2404) and the lint/build tooling (ci).
|
||||||
#
|
#
|
||||||
# Never on pull_request: a workflow file comes from the PR head, so a fork PR could
|
# Never on pull_request: a workflow file comes from the PR head, so a fork PR could
|
||||||
# otherwise push to the registry. This workflow has no pull_request trigger, and the job
|
# otherwise push to the registry. This workflow has no pull_request trigger, and the job
|
||||||
@@ -30,7 +31,10 @@ on: # yamllint disable-line rule:truthy
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
paths:
|
paths:
|
||||||
- 'images/molecule-ubuntu2404/**'
|
- 'images/**'
|
||||||
|
# The ci image bakes these two files' contents in (images/ci/Dockerfile).
|
||||||
|
- 'requirements-dev.txt'
|
||||||
|
- '.pre-commit-config.yaml'
|
||||||
- '.gitea/workflows/image.yml'
|
- '.gitea/workflows/image.yml'
|
||||||
tags:
|
tags:
|
||||||
- 'v*'
|
- 'v*'
|
||||||
@@ -53,13 +57,26 @@ jobs:
|
|||||||
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
(github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v'))
|
||||||
runs-on: kamino-docker
|
runs-on: kamino-docker
|
||||||
timeout-minutes: 45
|
timeout-minutes: 45
|
||||||
|
# One job at a time on the single-capacity runner. An empty subpath means the
|
||||||
|
# repository root is the build context.
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
max-parallel: 1
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- name: molecule-ubuntu2404
|
||||||
|
subpath: images/molecule-ubuntu2404
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
- name: ci
|
||||||
|
subpath: ""
|
||||||
|
dockerfile: images/ci/Dockerfile
|
||||||
container:
|
container:
|
||||||
image: ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac
|
image: ubuntu:24.04@sha256:68ee22004a9109b44973313b02ff7b1de250f1de0f5ecb628d73f579aaff33ac
|
||||||
# Keeps a runaway build from taking the whole 3 GB runner LXC down with it.
|
# Keeps a runaway build from taking the whole 3 GB runner LXC down with it.
|
||||||
options: --memory=2g --memory-swap=2g
|
options: --memory=2g --memory-swap=2g
|
||||||
env:
|
env:
|
||||||
DEBIAN_FRONTEND: noninteractive
|
DEBIAN_FRONTEND: noninteractive
|
||||||
IMAGE_PATH: mortis/molecule-ubuntu2404
|
IMAGE_PATH: mortis/${{ matrix.name }}
|
||||||
steps:
|
steps:
|
||||||
# A tag becomes the image tag. OCI tags cannot contain '+' (semver build metadata),
|
# A tag becomes the image tag. OCI tags cannot contain '+' (semver build metadata),
|
||||||
# and the trigger glob `v*` also matches names like `vfoo`: refuse both before
|
# and the trigger glob `v*` also matches names like `vfoo`: refuse both before
|
||||||
@@ -218,6 +235,8 @@ jobs:
|
|||||||
REF: ${{ github.ref }}
|
REF: ${{ github.ref }}
|
||||||
REF_NAME: ${{ github.ref_name }}
|
REF_NAME: ${{ github.ref_name }}
|
||||||
SHA: ${{ github.sha }}
|
SHA: ${{ github.sha }}
|
||||||
|
SUBPATH: ${{ matrix.subpath }}
|
||||||
|
DOCKERFILE: ${{ matrix.dockerfile }}
|
||||||
run: |
|
run: |
|
||||||
set +x
|
set +x
|
||||||
set -eu
|
set -eu
|
||||||
@@ -235,7 +254,10 @@ jobs:
|
|||||||
esac
|
esac
|
||||||
|
|
||||||
# Context: this commit of this repository, cloned by kaniko (#<ref>#<sha>:
|
# Context: this commit of this repository, cloned by kaniko (#<ref>#<sha>:
|
||||||
# clone <ref>, check out <sha>). The Dockerfile has no COPY, so only it is read.
|
# clone <ref>, check out <sha>). With a sub-path only that directory is the
|
||||||
|
# context (molecule image: its Dockerfile has no COPY).
|
||||||
|
ctx=(--dockerfile "$DOCKERFILE")
|
||||||
|
if [ -n "$SUBPATH" ]; then ctx+=(--context-sub-path "$SUBPATH"); fi
|
||||||
#
|
#
|
||||||
# When it finishes the executor has replaced the job container's filesystem with
|
# When it finishes the executor has replaced the job container's filesystem with
|
||||||
# the built image and removed /kaniko, so nothing written there (a --digest-file,
|
# the built image and removed /kaniko, so nothing written there (a --digest-file,
|
||||||
@@ -250,8 +272,7 @@ jobs:
|
|||||||
esac
|
esac
|
||||||
done < <(/kaniko/executor \
|
done < <(/kaniko/executor \
|
||||||
--context "git://${registry}/${REPO}.git#${REF}#${SHA}" \
|
--context "git://${registry}/${REPO}.git#${REF}#${SHA}" \
|
||||||
--context-sub-path images/molecule-ubuntu2404 \
|
"${ctx[@]}" \
|
||||||
--dockerfile Dockerfile \
|
|
||||||
"${dests[@]}" \
|
"${dests[@]}" \
|
||||||
--snapshot-mode=redo \
|
--snapshot-mode=redo \
|
||||||
--cache=false \
|
--cache=false \
|
||||||
@@ -267,7 +288,7 @@ jobs:
|
|||||||
echo "Pinned reference: ${image}@${digest}"
|
echo "Pinned reference: ${image}@${digest}"
|
||||||
if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then
|
if [ -n "${GITHUB_STEP_SUMMARY:-}" ]; then
|
||||||
{
|
{
|
||||||
echo "### molecule-ubuntu2404 pushed"
|
echo "### ${IMAGE_PATH} pushed"
|
||||||
echo
|
echo
|
||||||
echo "Pin it by digest: \`${image}@${digest}\`"
|
echo "Pin it by digest: \`${image}@${digest}\`"
|
||||||
} >> "$GITHUB_STEP_SUMMARY" || true
|
} >> "$GITHUB_STEP_SUMMARY" || true
|
||||||
|
|||||||
Reference in new issue
Block a user