Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
02f3548bd3 | ||
|
|
6c57250ec3 | ||
|
|
0cff3b373e | ||
|
|
737d5c58d7 | ||
|
|
af8e8a37e5 | ||
|
|
6bf0b3d0d7 | ||
|
|
c7a2d9f275 | ||
|
|
2ad7249d9f |
No files matched your search
@@ -75,20 +75,6 @@ jobs:
|
|||||||
username: ${{ secrets.CI_USER }}
|
username: ${{ secrets.CI_USER }}
|
||||||
password: ${{ secrets.CI_TOKEN }}
|
password: ${{ secrets.CI_TOKEN }}
|
||||||
|
|
||||||
# Cheap pre-check BEFORE the 10-20 minute build: tag exists, has exactly one amd64 entry,
|
|
||||||
# and has no arm64 entry yet (exit 3 otherwise). Writes nothing. The index digest read here
|
|
||||||
# is handed to the final step, which refuses if the tag moved in between.
|
|
||||||
- name: Plan (read the tag, no writes)
|
|
||||||
id: plan
|
|
||||||
env:
|
|
||||||
REPO: ${{ steps.v.outputs.repo }}
|
|
||||||
TAG: ${{ steps.v.outputs.tag }}
|
|
||||||
FORCE: ${{ steps.v.outputs.force }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
f=(); [ "$FORCE" = true ] && f=(--force)
|
|
||||||
scripts/attach-arm64-index.sh --repo "$REPO" --tag "$TAG" --plan-only "${f[@]}"
|
|
||||||
|
|
||||||
- name: Resolve base image digest (Docker Hub, direct)
|
- name: Resolve base image digest (Docker Hub, direct)
|
||||||
id: base
|
id: base
|
||||||
env:
|
env:
|
||||||
@@ -136,6 +122,21 @@ jobs:
|
|||||||
if: steps.pkgcache.outputs.mirror == ''
|
if: steps.pkgcache.outputs.mirror == ''
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
# (needs the buildx plugin, hence after the Buildx setup) Cheap pre-check BEFORE the long build: tag exists, has exactly one amd64 entry,
|
||||||
|
# and has no arm64 entry yet (exit 3 otherwise). Writes nothing. The index digest read here
|
||||||
|
# is handed to the final step, which refuses if the tag moved in between.
|
||||||
|
- name: Plan (read the tag, no writes)
|
||||||
|
id: plan
|
||||||
|
env:
|
||||||
|
REPO: ${{ steps.v.outputs.repo }}
|
||||||
|
TAG: ${{ steps.v.outputs.tag }}
|
||||||
|
FORCE: ${{ steps.v.outputs.force }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
docker buildx version
|
||||||
|
f=(); [ "$FORCE" = true ] && f=(--force)
|
||||||
|
scripts/attach-arm64-index.sh --repo "$REPO" --tag "$TAG" --plan-only "${f[@]}"
|
||||||
|
|
||||||
- name: Cache-bust value
|
- name: Cache-bust value
|
||||||
id: bust
|
id: bust
|
||||||
env:
|
env:
|
||||||
@@ -200,7 +201,13 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
want=$(docker run --rm --platform linux/amd64 --entrypoint php "$REPO@$AMD64" -r 'echo PHP_VERSION;')
|
want=$(docker run --rm --platform linux/amd64 --entrypoint php "$REPO@$AMD64" -r 'echo PHP_VERSION;')
|
||||||
got=$(docker run --rm --platform linux/arm64 --entrypoint php "$REPO@$ARM64_DIGEST" -r 'echo PHP_VERSION;')
|
# `docker run` of an arm64 image fails on this runner ("exec format error": no binfmt for the
|
||||||
|
# daemon), but BuildKit runs arm64 RUN steps under QEMU (that is how the image was built):
|
||||||
|
# run php in a throwaway build and export just the version file.
|
||||||
|
out=$(mktemp -d); ctx=$(mktemp -d)
|
||||||
|
printf 'FROM %s@%s AS src\nRUN php -r '"'"'echo PHP_VERSION;'"'"' > /pv\nFROM scratch\nCOPY --from=src /pv /pv\n' "$REPO" "$ARM64_DIGEST" |
|
||||||
|
docker buildx build --platform linux/arm64 --output "type=local,dest=$out" -f - "$ctx"
|
||||||
|
got=$(cat "$out/pv")
|
||||||
echo "amd64 (existing tag) PHP ${want}; new arm64 PHP ${got}"
|
echo "amd64 (existing tag) PHP ${want}; new arm64 PHP ${got}"
|
||||||
[[ "$want" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]] || { echo "::error::cannot read the amd64 PHP version"; exit 1; }
|
[[ "$want" =~ ^[0-9]+\.[0-9]+\.[0-9]+ ]] || { echo "::error::cannot read the amd64 PHP version"; exit 1; }
|
||||||
[ "$want" = "$got" ] || { echo "::error::PHP version differs between the existing amd64 (${want}) and the new arm64 (${got}); not attaching. The amd64 image needs a rebuild first."; exit 1; }
|
[ "$want" = "$got" ] || { echo "::error::PHP version differs between the existing amd64 (${want}) and the new arm64 (${got}); not attaching. The amd64 image needs a rebuild first."; exit 1; }
|
||||||
|
|||||||
@@ -73,9 +73,14 @@ bflag=(); [ -n "$builder" ] && bflag=(--builder "$builder")
|
|||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
it() { $IMAGETOOLS "$1" "${bflag[@]}" "${@:2}"; }
|
it() { $IMAGETOOLS "$1" "${bflag[@]}" "${@:2}"; }
|
||||||
|
|
||||||
# tag_digest <ref>: manifest (index) digest of a ref; empty on failure.
|
# tag_digest <ref>: manifest (index) digest of a ref = sha256 of its raw manifest bytes; empty on
|
||||||
|
# failure. (Not `--format {{.Manifest.Digest}}`: the CI runner's buildx 0.13.1 ignores it.)
|
||||||
tag_digest() {
|
tag_digest() {
|
||||||
it inspect "$1" --format '{{.Manifest.Digest}}' 2>/dev/null | tail -n 1 | tr -d '[:space:]' || true
|
local h
|
||||||
|
h=$(it inspect --raw "$1" 2>/dev/null | sha256sum | cut -d' ' -f1) || return 0
|
||||||
|
# sha256 of empty input means the inspect produced nothing
|
||||||
|
[ "$h" = e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 ] && return 0
|
||||||
|
echo "sha256:$h"
|
||||||
}
|
}
|
||||||
# arch_of <ref>: image config architecture; empty on failure.
|
# arch_of <ref>: image config architecture; empty on failure.
|
||||||
arch_of() {
|
arch_of() {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ if cmd == 'inspect':
|
|||||||
raw = '--raw' in rest
|
raw = '--raw' in rest
|
||||||
ref = [a for a in rest if not a.startswith('--') and not a.startswith('{{')][0] if not raw else rest[rest.index('--raw') + 1]
|
ref = [a for a in rest if not a.startswith('--') and not a.startswith('{{')][0] if not raw else rest[rest.index('--raw') + 1]
|
||||||
if raw:
|
if raw:
|
||||||
print(json.dumps(resolve(ref)[1]))
|
sys.stdout.write(json.dumps(resolve(ref)[1], sort_keys=True))
|
||||||
elif '{{.Manifest.Digest}}' in rest:
|
elif '{{.Manifest.Digest}}' in rest:
|
||||||
print(resolve(ref)[0])
|
print(resolve(ref)[0])
|
||||||
elif '{{json .Image}}' in rest:
|
elif '{{json .Image}}' in rest:
|
||||||
|
|||||||
@@ -417,8 +417,11 @@ class AttachWorkflow(unittest.TestCase):
|
|||||||
self.assertNotIn('linux/amd64', st)
|
self.assertNotIn('linux/amd64', st)
|
||||||
self.assertNotIn('Build amd64', self.job)
|
self.assertNotIn('Build amd64', self.job)
|
||||||
|
|
||||||
def test_nothing_but_the_script_writes_a_tag(self):
|
for bad in ('imagetools create', 'docker push', 'docker tag', '/cac:latest', '/cac-fpm:latest', 'ghcr.io'):
|
||||||
for bad in ('imagetools create', 'docker push', 'docker tag', '/cac:latest', '/cac-fpm:latest', 'ghcr.io', 'docker buildx build'):
|
self.assertNotIn(bad, self.job, bad)
|
||||||
|
self.assertEqual(self.job.count('docker buildx build'), 1) # only the local PHP-version probe
|
||||||
|
self.assertIn('type=local,dest=', self.job)
|
||||||
|
self.assertNotIn('--push', self.job)
|
||||||
self.assertNotIn(bad, self.job, bad)
|
self.assertNotIn(bad, self.job, bad)
|
||||||
self.assertEqual(self.job.count('scripts/attach-arm64-index.sh'), 2) # plan (read-only) + attach
|
self.assertEqual(self.job.count('scripts/attach-arm64-index.sh'), 2) # plan (read-only) + attach
|
||||||
self.assertIn('--plan-only', step(self.job, 'Plan'))
|
self.assertIn('--plan-only', step(self.job, 'Plan'))
|
||||||
|
|||||||
Reference in new issue
Block a user