Commit 6fef7815 authored by Benjamin Tissoires's avatar Benjamin Tissoires
Browse files

push a multi-arch manifest to quay.io



This simplifies the use of the templates, as we have a generic image
we can use.
This also allows to bring more arches without needing to add more arch
specific templates
Signed-off-by: Benjamin Tissoires's avatarBenjamin Tissoires <benjamin.tissoires@gmail.com>
parent 13ea575e
Pipeline #286901 passed with stages
in 3 minutes and 21 seconds
......@@ -214,37 +214,82 @@ pages:
#
.publish.template:
stage: publish
image: $CI_REGISTRY_IMAGE/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/buildah:2021-03-18.0
script:
- skopeo login --username "$QUAY_USER" --password "$(cat $QUAY_TOKEN)" quay.io
- set -x
- export LOCAL_IMAGE="$CI_REGISTRY_IMAGE/$LOCAL_IMAGE_SPEC"
- export DISTANT_IMAGE="quay.io/freedesktop.org/ci-templates:$DISTANT_IMAGE_SPEC"
# fetch the local and distant digest and layers to
# ensure the image is not already on the remote
# disable exit on failure
- set +e
# we store the labels and the sha of the layers
# we can not rely on the digest: the Name is different
# but the labels are set with the commit ID and the pipeline/job
# ids, which should ensure a correct match
- skopeo inspect docker://$LOCAL_IMAGE | jq '[.Labels, .Layers]' > local_sha
# we store the same information from the distant registry
- skopeo inspect docker://$DISTANT_IMAGE | jq '[.Labels, .Layers]' > distant_sha
# reenable exit on failure
- set -e
# if the distant repo has an image, ensure we use the same
# and finish the job if so
- diff distant_sha local_sha && exit 0 || true
# copy the original image into the distant registry
- skopeo copy docker://$LOCAL_IMAGE docker://$DISTANT_IMAGE
# transform the comma separated list into a space separated list
- FDO_ARCHITECTURES=${FDO_ARCHITECTURES//,/ }
# upload each individual layer if needed
- |
for FDO_ARCHITECTURE in $FDO_ARCHITECTURES
do
export LOCAL_IMAGE=$(eval echo -e "$CI_REGISTRY_IMAGE/$LOCAL_IMAGE_SPEC")
export DISTANT_IMAGE=$(eval echo -e "quay.io/freedesktop.org/ci-templates:$DISTANT_IMAGE_SPEC")
# fetch the local and distant digest and layers to
# ensure the image is not already on the remote
# disable exit on failure
set +e
# we store the labels and the sha of the layers
# we can not rely on the digest: the Name is different
# but the labels are set with the commit ID and the pipeline/job
# ids, which should ensure a correct match
skopeo inspect docker://$LOCAL_IMAGE | jq '[.Labels, .Layers]' > local_sha
# we store the same information from the distant registry
skopeo inspect docker://$DISTANT_IMAGE | jq '[.Labels, .Layers]' > distant_sha
# reenable exit on failure
set -e
# if the distant repo has an image, ensure we use the same
# and finish the job if so
diff distant_sha local_sha || touch .need_push
# copy the original image into the distant registry
if [[ -e .need_push ]]
then
rm .need_push
skopeo copy docker://$LOCAL_IMAGE docker://$DISTANT_IMAGE
fi
done
# build and push a manifest
- |
FDO_ARCHITECTURE=''
DISTANT_IMAGE=$(eval echo -e "/freedesktop.org/ci-templates:$DISTANT_IMAGE_SPEC")
MANIFEST=${DISTANT_IMAGE/--/-}
# remove leading '/'
export MANIFEST=${MANIFEST/\//}
buildah manifest create $MANIFEST
for FDO_ARCHITECTURE in $FDO_ARCHITECTURES
do
DISTANT_IMAGE=$(eval echo -e "quay.io/freedesktop.org/ci-templates:$DISTANT_IMAGE_SPEC")
buildah manifest add $MANIFEST $DISTANT_IMAGE
done
# check if we already have this manifest in the registry
buildah manifest inspect $MANIFEST > new_manifest.json
buildah manifest inspect docker://quay.io/$MANIFEST > current_manifest.json || true
diff -u current_manifest.json new_manifest.json || touch .need_push
# and push it
if [[ -e .need_push ]]
then
rm .need_push
buildah manifest push --format v2s2 --all \
$MANIFEST \
docker://quay.io/$MANIFEST
fi
- set +x
- skopeo logout quay.io
......@@ -262,25 +307,28 @@ publish to quay.io:
- buildah
SUFFIX:
- ''
FDO_ARCHITECTURE:
- x86_64
- aarch64
FDO_ARCHITECTURES:
- x86_64,aarch64
FDO_DISTRIBUTION_TAG:
- '2021-03-01.0'
- '2021-03-18.0'
- FDO_DISTRIBUTION_IMAGE:
- qemu
- qemu-mkosi
SUFFIX:
- '-base'
FDO_ARCHITECTURE:
FDO_ARCHITECTURES:
- x86_64
FDO_DISTRIBUTION_TAG:
- '2021-02-15.0'
- '2021-03-18.0'
variables:
# we want to keep the explicit variable (with '$') in `LOCAL_IMAGE_SPEC`
# given that there is only one variable expansion, we define it so that
# it doesn't get expanded in the job
FDO_ARCHITECTURE_VAR: $FDO_ARCHITECTURE
# local format, e.g. x86_64/mkosi-base-12324
# distant format, e.g. mkosi-base-x86_64-12324
LOCAL_IMAGE_SPEC: $FDO_ARCHITECTURE/${FDO_DISTRIBUTION_IMAGE}${SUFFIX}:${FDO_DISTRIBUTION_TAG}
DISTANT_IMAGE_SPEC: $FDO_DISTRIBUTION_IMAGE${SUFFIX}-$FDO_ARCHITECTURE-${FDO_DISTRIBUTION_TAG}
LOCAL_IMAGE_SPEC: ${FDO_ARCHITECTURE_VAR}/${FDO_DISTRIBUTION_IMAGE}${SUFFIX}:${FDO_DISTRIBUTION_TAG}
DISTANT_IMAGE_SPEC: $FDO_DISTRIBUTION_IMAGE${SUFFIX}-${FDO_ARCHITECTURE_VAR}-${FDO_DISTRIBUTION_TAG}
rules:
- if: '$CI_COMMIT_BRANCH == "master" && $CI_PROJECT_PATH == "freedesktop/ci-templates"'
......@@ -292,6 +340,7 @@ publish ci-fairy to quay.io:
- .ci-fairy-tag
- .publish.template
variables:
FDO_ARCHITECTURES: x86_64
LOCAL_IMAGE_SPEC: ci-fairy:$FDO_DISTRIBUTION_TAG
DISTANT_IMAGE_SPEC: ci-fairy-$FDO_DISTRIBUTION_TAG
rules:
......@@ -302,13 +351,12 @@ publish ci-fairy to quay.io:
# exist
#
test published images:
image: $CI_REGISTRY_IMAGE/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/buildah:2021-03-18.0
stage: test published images
script:
- skopeo inspect docker://quay.io/freedesktop.org/ci-templates:buildah-aarch64-2021-03-01.0
- skopeo inspect docker://quay.io/freedesktop.org/ci-templates:buildah-x86_64-2021-03-01.0
- skopeo inspect docker://quay.io/freedesktop.org/ci-templates:buildah-2021-03-18.0
- skopeo inspect docker://quay.io/freedesktop.org/ci-templates:ci-fairy-sha256-41ee4d1ca15ea24c7d171a573fab18538561e526253b742b8172dd7a6412035f
- skopeo inspect docker://quay.io/freedesktop.org/ci-templates:qemu-base-x86_64-2021-02-15.0
- skopeo inspect docker://quay.io/freedesktop.org/ci-templates:qemu-mkosi-base-x86_64-2021-02-15.0
- skopeo inspect docker://quay.io/freedesktop.org/ci-templates:qemu-base-2021-03-18.0
- skopeo inspect docker://quay.io/freedesktop.org/ci-templates:qemu-mkosi-base-2021-03-18.0
rules:
- if: '$CI_COMMIT_BRANCH == "master" && $CI_PROJECT_PATH == "freedesktop/ci-templates"'
\ No newline at end of file
......@@ -21,7 +21,7 @@ stages:
# Common variable definitions
#
.ci-commons-alpine:
image: $CI_REGISTRY_IMAGE/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/buildah:2021-03-18.0
variables:
FDO_DISTRIBUTION_PACKAGES: 'wget curl'
FDO_DISTRIBUTION_EXEC: 'sh test/script.sh'
......@@ -195,7 +195,7 @@ do not rebuild alpine:latest@container-build@x86_64:
check labels alpine@x86_64:latest:
extends:
- alpine:latest@check@x86_64
image: $CI_REGISTRY_IMAGE/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/buildah:2021-03-18.0
script:
# FDO_DISTRIBUTION_IMAGE still has indirections
- DISTRO_IMAGE=$(eval echo ${FDO_DISTRIBUTION_IMAGE})
......
......@@ -21,7 +21,7 @@ stages:
# Common variable definitions
#
.ci-commons-arch:
image: $CI_REGISTRY_IMAGE/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/buildah:2021-03-18.0
variables:
FDO_DISTRIBUTION_PACKAGES: 'wget curl'
FDO_DISTRIBUTION_EXEC: 'sh test/script.sh'
......@@ -170,7 +170,7 @@ do not rebuild arch:rolling@container-build@x86_64:
check labels arch@x86_64:rolling:
extends:
- arch:rolling@check@x86_64
image: $CI_REGISTRY_IMAGE/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/buildah:2021-03-18.0
script:
# FDO_DISTRIBUTION_IMAGE still has indirections
- DISTRO_IMAGE=$(eval echo ${FDO_DISTRIBUTION_IMAGE})
......
......@@ -21,7 +21,7 @@ stages:
variables:
FDO_UPSTREAM_REPO: freedesktop/ci-templates
FDO_DISTRIBUTION_VERSION: '33'
FDO_DISTRIBUTION_TAG: '2021-03-01.0'
FDO_DISTRIBUTION_TAG: '2021-03-18.0'
# Builds an image that the .fdo.container-build@ templates run on
......@@ -53,20 +53,20 @@ bootstrap@aarch64:
bootstrap@local-manifest:
extends:
- .bootstrap_skeleton
image: $CI_REGISTRY_IMAGE/x86_64/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/x86_64/buildah:2021-03-18.0
stage: bootstrapping manifest
script:
# log in to the registry
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
# create the multi-arch manifest
- buildah manifest create buildah:2021-03-01.0
$CI_REGISTRY_IMAGE/x86_64/buildah:2021-03-01.0
$CI_REGISTRY_IMAGE/aarch64/buildah:2021-03-01.0
- buildah manifest create buildah:2021-03-18.0
$CI_REGISTRY_IMAGE/x86_64/buildah:2021-03-18.0
$CI_REGISTRY_IMAGE/aarch64/buildah:2021-03-18.0
# check if we already have this manifest in the registry
- buildah manifest inspect buildah:2021-03-01.0 > new_manifest.json
- buildah manifest inspect docker://$CI_REGISTRY_IMAGE/buildah:2021-03-01.0 > current_manifest.json || true
- buildah manifest inspect buildah:2021-03-18.0 > new_manifest.json
- buildah manifest inspect docker://$CI_REGISTRY_IMAGE/buildah:2021-03-18.0 > current_manifest.json || true
- diff -u current_manifest.json new_manifest.json || touch .need_push
......@@ -76,8 +76,8 @@ bootstrap@local-manifest:
then
rm .need_push
buildah manifest push --format v2s2 --all \
buildah:2021-03-01.0 \
docker://$CI_REGISTRY_IMAGE/buildah:2021-03-01.0
buildah:2021-03-18.0 \
docker://$CI_REGISTRY_IMAGE/buildah:2021-03-18.0
fi
needs:
- bootstrap@aarch64
......@@ -94,12 +94,12 @@ bootstrap@local-manifest:
# - usbutils (for being able to call lsusb and redirect part a USB device)
bootstrap-qemu@x86_64:
extends: .bootstrap_skeleton
image: $CI_REGISTRY_IMAGE/x86_64/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/x86_64/buildah:2021-03-18.0
stage: bootstrapping_qemu
dependencies: []
variables:
FDO_DISTRIBUTION_TAG: '2021-02-15.0'
FDO_BASE_IMAGE: $CI_REGISTRY_IMAGE/x86_64/buildah:2021-03-01.0
FDO_DISTRIBUTION_TAG: '2021-03-18.0'
FDO_BASE_IMAGE: $CI_REGISTRY_IMAGE/x86_64/buildah:2021-03-18.0
FDO_REPO_SUFFIX: x86_64/qemu-base
FDO_DISTRIBUTION_PACKAGES: 'qemu genisoimage usbutils'
FDO_DISTRIBUTION_EXEC: 'mkdir -p /app && cp bootstrap/vmctl.sh /app/vmctl'
......
......@@ -21,7 +21,7 @@ stages:
# Common variable definitions
#
.ci-commons-centos:
image: $CI_REGISTRY_IMAGE/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/buildah:2021-03-18.0
variables:
FDO_DISTRIBUTION_PACKAGES: 'wget curl'
FDO_DISTRIBUTION_EXEC: 'sh test/script.sh'
......@@ -171,7 +171,7 @@ do not rebuild centos:7@container-build@x86_64:
check labels centos@x86_64:7:
extends:
- centos:7@check@x86_64
image: $CI_REGISTRY_IMAGE/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/buildah:2021-03-18.0
script:
# FDO_DISTRIBUTION_IMAGE still has indirections
- DISTRO_IMAGE=$(eval echo ${FDO_DISTRIBUTION_IMAGE})
......
......@@ -6,7 +6,7 @@ stages:
- image build
.local buildah image:
image: $CI_REGISTRY_IMAGE/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/buildah:2021-03-18.0
# The ci-fairy base image. We build a base image that we can bump independently
# via the tag, ci-fairy itself gets layered on top with each commit.
......
......@@ -21,7 +21,7 @@ stages:
# Common variable definitions
#
.ci-commons-debian:
image: $CI_REGISTRY_IMAGE/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/buildah:2021-03-18.0
variables:
FDO_DISTRIBUTION_PACKAGES: 'wget curl'
FDO_DISTRIBUTION_EXEC: 'sh test/script.sh'
......@@ -64,7 +64,7 @@ stages:
extends:
- .fdo.qemu-build@debian@x86_64
- .ci-commons-debian@x86_64
image: $CI_REGISTRY_IMAGE/x86_64/qemu-mkosi-base:2021-02-15.0
image: $CI_REGISTRY_IMAGE/x86_64/qemu-mkosi-base:2021-03-18.0
stage: debian_container_build
artifacts:
name: logs-$CI_PIPELINE_ID
......@@ -231,7 +231,7 @@ debian:buster@qemu-build@x86_64:
variables:
FDO_DISTRIBUTION_TAG: fdo-ci-qemu-x86_64-$CI_PIPELINE_ID
FDO_DISTRIBUTION_PACKAGES: 'wget curl'
QEMU_BASE_IMAGE: $CI_REGISTRY_IMAGE/x86_64/qemu-base:2021-02-15.0
QEMU_BASE_IMAGE: $CI_REGISTRY_IMAGE/x86_64/qemu-base:2021-03-18.0
debian:buster@qemu-check@x86_64:
......@@ -261,7 +261,7 @@ do not rebuild debian:buster@container-build@x86_64:
check labels debian@x86_64:buster:
extends:
- debian:buster@check@x86_64
image: $CI_REGISTRY_IMAGE/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/buildah:2021-03-18.0
script:
# FDO_DISTRIBUTION_IMAGE still has indirections
- DISTRO_IMAGE=$(eval echo ${FDO_DISTRIBUTION_IMAGE})
......
......@@ -21,7 +21,7 @@ stages:
# Common variable definitions
#
.ci-commons-fedora:
image: $CI_REGISTRY_IMAGE/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/buildah:2021-03-18.0
variables:
FDO_DISTRIBUTION_PACKAGES: 'wget curl'
FDO_DISTRIBUTION_EXEC: 'sh test/script.sh'
......@@ -64,7 +64,7 @@ stages:
extends:
- .fdo.qemu-build@fedora@x86_64
- .ci-commons-fedora@x86_64
image: $CI_REGISTRY_IMAGE/x86_64/qemu-mkosi-base:2021-02-15.0
image: $CI_REGISTRY_IMAGE/x86_64/qemu-mkosi-base:2021-03-18.0
stage: fedora_container_build
artifacts:
name: logs-$CI_PIPELINE_ID
......@@ -231,7 +231,7 @@ fedora:33@qemu-build@x86_64:
variables:
FDO_DISTRIBUTION_TAG: fdo-ci-qemu-x86_64-$CI_PIPELINE_ID
FDO_DISTRIBUTION_PACKAGES: 'wget curl'
QEMU_BASE_IMAGE: $CI_REGISTRY_IMAGE/x86_64/qemu-base:2021-02-15.0
QEMU_BASE_IMAGE: $CI_REGISTRY_IMAGE/x86_64/qemu-base:2021-03-18.0
fedora:33@qemu-check@x86_64:
......@@ -261,7 +261,7 @@ do not rebuild fedora:33@container-build@x86_64:
check labels fedora@x86_64:33:
extends:
- fedora:33@check@x86_64
image: $CI_REGISTRY_IMAGE/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/buildah:2021-03-18.0
script:
# FDO_DISTRIBUTION_IMAGE still has indirections
- DISTRO_IMAGE=$(eval echo ${FDO_DISTRIBUTION_IMAGE})
......
......@@ -21,7 +21,7 @@ stages:
# Common variable definitions
#
.ci-commons-ubuntu:
image: $CI_REGISTRY_IMAGE/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/buildah:2021-03-18.0
variables:
FDO_DISTRIBUTION_PACKAGES: 'wget curl'
FDO_DISTRIBUTION_EXEC: 'sh test/script.sh'
......@@ -64,7 +64,7 @@ stages:
extends:
- .fdo.qemu-build@ubuntu@x86_64
- .ci-commons-ubuntu@x86_64
image: $CI_REGISTRY_IMAGE/x86_64/qemu-mkosi-base:2021-02-15.0
image: $CI_REGISTRY_IMAGE/x86_64/qemu-mkosi-base:2021-03-18.0
stage: ubuntu_container_build
artifacts:
name: logs-$CI_PIPELINE_ID
......@@ -231,7 +231,7 @@ ubuntu:20.10@qemu-build@x86_64:
variables:
FDO_DISTRIBUTION_TAG: fdo-ci-qemu-x86_64-$CI_PIPELINE_ID
FDO_DISTRIBUTION_PACKAGES: 'wget curl'
QEMU_BASE_IMAGE: $CI_REGISTRY_IMAGE/x86_64/qemu-base:2021-02-15.0
QEMU_BASE_IMAGE: $CI_REGISTRY_IMAGE/x86_64/qemu-base:2021-03-18.0
ubuntu:20.10@qemu-check@x86_64:
......@@ -261,7 +261,7 @@ do not rebuild ubuntu:20.10@container-build@x86_64:
check labels ubuntu@x86_64:20.10:
extends:
- ubuntu:20.10@check@x86_64
image: $CI_REGISTRY_IMAGE/buildah:2021-03-01.0
image: $CI_REGISTRY_IMAGE/buildah:2021-03-18.0
script:
# FDO_DISTRIBUTION_IMAGE still has indirections
- DISTRO_IMAGE=$(eval echo ${FDO_DISTRIBUTION_IMAGE})
......
## @bootstrap_tag: the current image tag associated with this bootstrap image
bootstrap_tag: '2021-03-01.0'
bootstrap_tag: '2021-03-18.0'
## @qemu_tag: the current image tag associated with this qemu bootstrap image
qemu_tag: '2021-02-15.0'
qemu_tag: '2021-03-18.0'
## @ci_templates_registry_path: the path to where the templates should look
## for bootstrap images.
......
......@@ -259,7 +259,7 @@
# .. code-block:: yaml
#
# my-{{distribution}}-image:
# extends: .fdo.container-build@{{distribution}}@x86_64
# extends: .fdo.container-build@{{distribution}}
# variables:
# FDO_DISTRIBUTION_PACKAGES: 'curl wget gcc valgrind'
{% if not fixed_version %}
......@@ -353,14 +353,16 @@
{% endif %}
# Use the ``.fdo.distribution-image@{{distribution}}`` template to access or use this image.
#
.fdo.container-build@{{distribution}}@x86_64:
.fdo.container-build@{{distribution}}:
extends: .fdo.container-build-common@{{distribution}}
image: {{ci_templates_registry}}{{ci_templates_registry_path}}:buildah-x86_64-{{bootstrap_tag}}
image: {{ci_templates_registry}}{{ci_templates_registry_path}}:buildah-{{bootstrap_tag}}
###
# Alias to ``.fdo.container-build@{{distribution}}@x86_64``.
.fdo.container-build@{{distribution}}:
extends: .fdo.container-build@{{distribution}}@x86_64
# Alias to ``.fdo.container-build@{{distribution}}``.
#
# This template is deprecated, no need to specify the architecture anymore.
.fdo.container-build@{{distribution}}@x86_64:
extends: .fdo.container-build@{{distribution}}
{% if aarch64 %}
......@@ -370,10 +372,12 @@
#
# This template requires runners with the ``aarch64`` tag.
#
# See ``.fdo.container-build@{{distribution}}@x86_64`` for details.
# See ``.fdo.container-build@{{distribution}}`` for details.
#
# This template is deprecated. It is best if users use the non architecture
# specific variant and define themselves the tags to chose the runner.
.fdo.container-build@{{distribution}}@aarch64:
extends: .fdo.container-build-common@{{distribution}}
image: {{ci_templates_registry}}{{ci_templates_registry_path}}:buildah-aarch64-{{bootstrap_tag}}
tags:
- aarch64
{% endif %}
......@@ -386,12 +390,12 @@
#
# This template requires runners with the ``kvm`` tag.
#
# See ``.fdo.container-build@{{distribution}}@x86_64`` for details.
# See ``.fdo.container-build@{{distribution}}`` for details.
.fdo.qemu-build@{{distribution}}@x86_64:
extends: .fdo.container-build@{{distribution}}@x86_64
extends: .fdo.container-build@{{distribution}}
tags:
- kvm
image: {{ci_templates_registry}}{{ci_templates_registry_path}}:qemu-mkosi-base-x86_64-{{qemu_tag}}
image: {{ci_templates_registry}}{{ci_templates_registry_path}}:qemu-mkosi-base-{{qemu_tag}}
script:
# log in to the registry
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
......@@ -510,7 +514,7 @@
graphroot = "/var/lib/containers/storage"
EOF
- QEMU_BASE_IMAGE=${QEMU_BASE_IMAGE:-{{ci_templates_registry}}{{ci_templates_registry_path}}:qemu-base-x86_64-{{qemu_tag}}}
- QEMU_BASE_IMAGE=${QEMU_BASE_IMAGE:-{{ci_templates_registry}}{{ci_templates_registry_path}}:qemu-base-{{qemu_tag}}}
- echo Building $FDO_REPO_SUFFIX:$DISTRO_TAG from $QEMU_BASE_IMAGE
......@@ -555,6 +559,9 @@
- set +x
# Alias to ``.fdo.qemu-build@{{distribution}}@x86_64``
#
# This template is deprecated, use ``.fdo.qemu-build@{{distribution}}@x86_64``
# instead
.fdo.qemu-build@{{distribution}}:
extends: .fdo.qemu-build@{{distribution}}@x86_64
{% endif %}
......@@ -563,7 +570,7 @@
# {{distribution}} template that pulls the {{distribution}} image from the
# registry based on {% if not fixed_version %}``FDO_DISTRIBUTION_VERSION`` and {% endif -%} ``FDO_DISTRIBUTION_TAG``.
# This template must be provided the same variable values as supplied in
# ``.fdo.container-build@{{distribution}}@x86_64``.
# ``.fdo.container-build@{{distribution}}``.
#
# This template sets ``image:`` to the generated image. You may override this.
#
......@@ -592,7 +599,7 @@
# The {{distribution}} version to build, e.g. '{{versions|join('\', \'')}}'
#
# The value supplied must be the same as supplied in
# ``.fdo.container-build@{{distribution}}@x86_64``.
# ``.fdo.container-build@{{distribution}}``.
#
{% endif %}
# .. attribute:: FDO_DISTRIBUTION_TAG
......@@ -602,7 +609,7 @@
# String to identify the image in the registry.
#
# The value supplied must be the same as supplied in
# ``.fdo.container-build@{{distribution}}@x86_64``.
# ``.fdo.container-build@{{distribution}}``.
#
# .. attribute:: FDO_DISTRIBUTION_IMAGE
#
......@@ -636,7 +643,7 @@
# {{distribution}} template that pulls the {{distribution}} image from the
# registry based on ``FDO_REPO_SUFFIX``.
# This template must be provided the same variable values as supplied in
# ``.fdo.container-build@{{distribution}}@x86_64``.
# ``.fdo.container-build@{{distribution}}``.
#
# This template sets ``image:`` to the generated image. You may override this.
#
......@@ -644,7 +651,7 @@
#
# .. code-block:: yaml
#
# my-{{distribution}}-test@x86_64:
# my-{{distribution}}-test:
# extends: .fdo.distribution-image@{{distribution}}
# variables:
# FDO_REPO_SUFFIX: 'some/path'
......@@ -663,7 +670,7 @@
# The repository name suffix.
#
# The value supplied must be the same as supplied in
# ``.fdo.container-build@{{distribution}}@x86_64``.
# ``.fdo.container-build@{{distribution}}``.
#
# .. attribute:: FDO_DISTRIBUTION_TAG
#
......@@ -672,7 +679,7 @@
# String to identify the image in the registry.
#
# The value supplied must be the same as supplied in
# ``.fdo.container-build@{{distribution}}@x86_64``.
# ``.fdo.container-build@{{distribution}}``.
#
# .. attribute:: FDO_DISTRIBUTION_IMAGE
#
......
......@@ -185,33 +185,78 @@ pages:
script:
- skopeo login --username "$QUAY_USER" --password "$(cat $QUAY_TOKEN)" {{ci_templates_registry}}
- set -x
- export LOCAL_IMAGE="$CI_REGISTRY_IMAGE/$LOCAL_IMAGE_SPEC"
- export DISTANT_IMAGE="{{ci_templates_registry}}{{ci_templates_registry_path}}:$DISTANT_IMAGE_SPEC"
# fetch the local and distant digest and layers to
# ensure the image is not already on the remote
# disable exit on failure
- set +e
# we store the labels and the sha of the layers
# we can not rely on the digest: the Name is different
# but the labels are set with the commit ID and the pipeline/job
# ids, which should ensure a correct match
- skopeo inspect docker://$LOCAL_IMAGE | jq '[.Labels, .Layers]' > local_sha
# we store the same information from the distant registry
- skopeo inspect docker://$DISTANT_IMAGE | jq '[.Labels, .Layers]' > distant_sha
# reenable exit on failure
- set -e
# if the distant repo has an image, ensure we use the same
# and finish the job if so
- diff distant_sha local_sha && exit 0 || true
# copy the original image into the distant registry
- skopeo copy docker://$LOCAL_IMAGE docker://$DISTANT_IMAGE
# transform the comma separated list into a space separated list
- FDO_ARCHITECTURES=${FDO_ARCHITECTURES//,/ }
# upload each individual layer if needed
- |
for FDO_ARCHITECTURE in $FDO_ARCHITECTURES
do
export LOCAL_IMAGE=$(eval echo -e "$CI_REGISTRY_IMAGE/$LOCAL_IMAGE_SPEC")
export DISTANT_IMAGE=$(eval echo -e "{{ci_templates_registry}}{{ci_templates_registry_path}}:$DISTANT_IMAGE_SPEC")
# fetch the local and distant digest and layers to
# ensure the image is not already on the remote
# disable exit on failure
set +e
# we store the labels and the sha of the layers
# we can not rely on the digest: the Name is different
# but the labels are set with the commit ID and the pipeline/job
# ids, which should ensure a correct match
skopeo inspect docker://$LOCAL_IMAGE | jq '[.Labels, .Layers]' > local_sha
# we store the same information from the distant registry
skopeo inspect docker://$DISTANT_IMAGE | jq '[.Labels, .Layers]' > distant_sha
# reenable exit on failure
set -e
# if the distant repo has an image, ensure we use the same
# and finish the job if so
diff distant_sha local_sha || touch .need_push
# copy the original image into the distant registry
if [[ -e .need_push ]]
then
rm .need_push
skopeo copy docker://$LOCAL_IMAGE docker://$DISTANT_IMAGE
fi
done
# build and push a manifest
- |
FDO_ARCHITECTURE=''
DISTANT_IMAGE=$(eval echo -e "{{ci_templates_registry_path}}:$DISTANT_IMAGE_SPEC")
MANIFEST=${DISTANT_IMAGE/--/-}
# remove leading '/'
export MANIFEST=${MANIFEST/\//}
buildah manifest create $MANIFEST
for FDO_ARCHITECTURE in $FDO_ARCHITECTURES
do
DISTANT_IMAGE=$(eval echo -e "{{ci_templates_registry}}{{ci_templates_registry_path}}:$DISTANT_IMAGE_SPEC")