Commit ddecb22a authored by Benjamin Tissoires's avatar Benjamin Tissoires
Browse files

FDO_REPO_SUFFIX: remove the distribution before



This is an API break, but it doesn't really make sense to prepend
the type of distribution when we manually specify the repo suffix.

This will allow us to use the templates to bootstrap the buildah image.
Signed-off-by: Benjamin Tissoires's avatarBenjamin Tissoires <benjamin.tissoires@gmail.com>
parent ae0a4165
......@@ -206,7 +206,7 @@ alpine:latest-upstream@container-ifnot-exists:
stage: alpine_check
variables:
FDO_UPSTREAM_REPO: $CI_PROJECT_PATH
FDO_REPO_SUFFIX: ci_templates_test_upstream
FDO_REPO_SUFFIX: alpine/ci_templates_test_upstream
FDO_DISTRIBUTION_PACKAGES: 'this-package-should-not-exist'
needs:
- alpine-forced:latest@container-ifnot-exists
......
......@@ -168,7 +168,7 @@ arch:rolling-upstream@container-ifnot-exists:
stage: arch_check
variables:
FDO_UPSTREAM_REPO: $CI_PROJECT_PATH
FDO_REPO_SUFFIX: ci_templates_test_upstream
FDO_REPO_SUFFIX: arch/ci_templates_test_upstream
FDO_DISTRIBUTION_PACKAGES: 'this-package-should-not-exist'
needs:
- arch-forced:rolling@container-ifnot-exists
......
......@@ -169,7 +169,7 @@ centos:7-upstream@container-ifnot-exists:
stage: centos_check
variables:
FDO_UPSTREAM_REPO: $CI_PROJECT_PATH
FDO_REPO_SUFFIX: ci_templates_test_upstream
FDO_REPO_SUFFIX: centos/ci_templates_test_upstream
FDO_DISTRIBUTION_PACKAGES: 'this-package-should-not-exist'
needs:
- centos-forced:7@container-ifnot-exists
......
......@@ -68,7 +68,7 @@
extends:
- .fdo.qemu-build@debian
- .ci-commons-debian
image: $CI_REGISTRY_IMAGE/fedora/qemu-mkosi-base:$QEMU_TAG
image: $CI_REGISTRY_IMAGE/qemu-mkosi-base:$QEMU_TAG
stage: debian_container_build
artifacts:
name: logs-$CI_PIPELINE_ID
......@@ -228,7 +228,7 @@ debian:stretch@qemu-build:
variables:
FDO_DISTRIBUTION_TAG: fdo-ci-qemu-$CI_PIPELINE_ID
FDO_DISTRIBUTION_PACKAGES: 'wget curl'
QEMU_BASE_IMAGE: $CI_REGISTRY_IMAGE/fedora/qemu-base:$QEMU_TAG
QEMU_BASE_IMAGE: $CI_REGISTRY_IMAGE/qemu-base:$QEMU_TAG
debian:stretch@qemu-check:
......@@ -281,7 +281,7 @@ debian:stretch-upstream@container-ifnot-exists:
stage: debian_check
variables:
FDO_UPSTREAM_REPO: $CI_PROJECT_PATH
FDO_REPO_SUFFIX: ci_templates_test_upstream
FDO_REPO_SUFFIX: debian/ci_templates_test_upstream
FDO_DISTRIBUTION_PACKAGES: 'this-package-should-not-exist'
needs:
- debian-forced:stretch@container-ifnot-exists
......
......@@ -68,7 +68,7 @@
extends:
- .fdo.qemu-build@fedora
- .ci-commons-fedora
image: $CI_REGISTRY_IMAGE/fedora/qemu-mkosi-base:$QEMU_TAG
image: $CI_REGISTRY_IMAGE/qemu-mkosi-base:$QEMU_TAG
stage: fedora_container_build
artifacts:
name: logs-$CI_PIPELINE_ID
......@@ -228,7 +228,7 @@ fedora:31@qemu-build:
variables:
FDO_DISTRIBUTION_TAG: fdo-ci-qemu-$CI_PIPELINE_ID
FDO_DISTRIBUTION_PACKAGES: 'wget curl'
QEMU_BASE_IMAGE: $CI_REGISTRY_IMAGE/fedora/qemu-base:$QEMU_TAG
QEMU_BASE_IMAGE: $CI_REGISTRY_IMAGE/qemu-base:$QEMU_TAG
fedora:31@qemu-check:
......@@ -281,7 +281,7 @@ fedora:31-upstream@container-ifnot-exists:
stage: fedora_check
variables:
FDO_UPSTREAM_REPO: $CI_PROJECT_PATH
FDO_REPO_SUFFIX: ci_templates_test_upstream
FDO_REPO_SUFFIX: fedora/ci_templates_test_upstream
FDO_DISTRIBUTION_PACKAGES: 'this-package-should-not-exist'
needs:
- fedora-forced:31@container-ifnot-exists
......
......@@ -73,7 +73,7 @@
extends:
- .fdo.qemu-build@{{distribution}}
- .ci-commons-{{distribution}}
image: $CI_REGISTRY_IMAGE/fedora/qemu-mkosi-base:$QEMU_TAG
image: $CI_REGISTRY_IMAGE/qemu-mkosi-base:$QEMU_TAG
stage: {{distribution}}_container_build
artifacts:
name: logs-$CI_PIPELINE_ID
......@@ -241,7 +241,7 @@
variables:
FDO_DISTRIBUTION_TAG: fdo-ci-qemu-$CI_PIPELINE_ID
FDO_DISTRIBUTION_PACKAGES: 'wget curl'
QEMU_BASE_IMAGE: $CI_REGISTRY_IMAGE/fedora/qemu-base:$QEMU_TAG
QEMU_BASE_IMAGE: $CI_REGISTRY_IMAGE/qemu-base:$QEMU_TAG
{{distribution}}:{{ versions[0] }}@qemu-check:
......@@ -295,7 +295,7 @@
stage: {{distribution}}_check
variables:
FDO_UPSTREAM_REPO: $CI_PROJECT_PATH
FDO_REPO_SUFFIX: ci_templates_test_upstream
FDO_REPO_SUFFIX: {{distribution}}/ci_templates_test_upstream
FDO_DISTRIBUTION_PACKAGES: 'this-package-should-not-exist'
needs:
- {{distribution}}-forced:{{ versions[0] }}@container-ifnot-exists
......
......@@ -15,9 +15,10 @@
# - FDO_UPSTREAM_REPO: the upstream project on this gitlab instance
# where we might find the given tag (for example:
# `wayland/weston`)
# - FDO_REPO_SUFFIX: The repository name suffix after ".../{{distribution}}/".
# - FDO_REPO_SUFFIX: The repository name suffix.
# If this variable isn't defined,
# "$FDO_DISTRIBUTION_VERSION" is used for the suffix.
# "{{distribution}}/$FDO_DISTRIBUTION_VERSION" is used for
# the suffix.
# - FDO_DISTRIBUTION_TAG: tag to copy the image from the upstream registry. If the
# tag does not exist, create a new build and tag it
# - FDO_CACHE_DIR: A directory that needs to be mounted as `/cache` during
......@@ -25,7 +26,7 @@
# host, so that most users should not need this.
#
# The resulting image will be pushed in the local registry, under:
# $CI_REGISTRY_IMAGE/{{distribution}}/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
# $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
#
# Two flavors of templates are available:
# - `.fdo.container-build@{{distribution}}`: this will force rebuild a new container
......@@ -51,7 +52,7 @@
export DISTRO_EXEC=$FDO_DISTRIBUTION_EXEC
if [ x"$FDO_REPO_SUFFIX" == x"" ] ;
then
export FDO_REPO_SUFFIX=$DISTRO_VERSION
export FDO_REPO_SUFFIX={{distribution}}/$DISTRO_VERSION
fi
export BUILDAH_RUN="buildah run --isolation chroot"
export BUILDAH_COMMIT="buildah commit --format docker"
......@@ -82,7 +83,7 @@
# The resulting image will be pushed to the local registry.
#
# If the repository suffix was specified, the image path is
# ``$CI_REGISTRY_IMAGE/{{distribution}}/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG``. The
# ``$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG``. The
# ``.fdo.suffixed_image@{{distribution}}`` template provides access to this image.
#
# If the repository suffix was **not** specified, the image path is
......@@ -107,7 +108,7 @@
echo $DISTRO tag missing;
exit 1;
fi
- echo Building $DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG from {{ image }}
- echo Building $FDO_REPO_SUFFIX:$DISTRO_TAG from {{ image }}
# initial set up: take the base image, update it and install the packages
- buildcntr=$(buildah from {{ image }})
- buildmnt=$(buildah mount $buildcntr)
......@@ -162,7 +163,7 @@
# umount the container, not required, but, heh
- buildah unmount $buildcntr
# tag the current container
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
# clean up the working container
- buildah rm $buildcntr
......@@ -170,16 +171,16 @@
# There is a bug when pushing 2 tags in the same repo with the same base:
# this may fail. Just retry it after.
- export JOB_TAG="${DISTRO_TAG}-built-by-job-${CI_JOB_ID}"
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$JOB_TAG || true
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$JOB_TAG || true
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$JOB_TAG || true
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$JOB_TAG || true
# Push the final tag
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG || true
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG || true
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
{% if aarch64 %}
###
......@@ -208,7 +209,7 @@
extends: .fdo.container-build@{{distribution}}
tags:
- kvm
image: $CI_REGISTRY/freedesktop/ci-templates/fedora/qemu-mkosi-base:{{ qemu_tag }}
image: $CI_REGISTRY/freedesktop/ci-templates/qemu-mkosi-base:{{ qemu_tag }}
script:
# log in to the registry
- podman login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
......@@ -321,9 +322,9 @@
graphroot = "/var/lib/containers/storage"
EOF
- QEMU_BASE_IMAGE=${QEMU_BASE_IMAGE:-$CI_REGISTRY/freedesktop/ci-templates/fedora/qemu-base:{{ qemu_tag }}}
- QEMU_BASE_IMAGE=${QEMU_BASE_IMAGE:-$CI_REGISTRY/freedesktop/ci-templates/qemu-base:{{ qemu_tag }}}
- echo Building $DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG from $QEMU_BASE_IMAGE
- echo Building $FDO_REPO_SUFFIX:$DISTRO_TAG from $QEMU_BASE_IMAGE
- buildcntr=$(buildah from $QEMU_BASE_IMAGE)
- buildmnt=$(buildah mount $buildcntr)
......@@ -367,7 +368,7 @@
- buildah unmount $buildcntr
# tag the current container
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
# clean up the working container
- buildah rm $buildcntr
......@@ -375,9 +376,9 @@
# push the container image to the registry
# There is a bug when pushing 2 tags in the same repo with the same base:
# this may fail. Just retry it after.
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG || true
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG || true
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
{% endif %}
.fdo.before_script_ifnot_exists: &fdo_before_script_ifnot_exists
......@@ -391,30 +392,30 @@
# project itself, we need to put a special case here to have a
# different image to pull if it already exists
- export REPO_SUFFIX_LOCAL=$FDO_REPO_SUFFIX
- if [[ x"$REPO_SUFFIX_LOCAL" == x"ci_templates_test_upstream" ]] ;
- if [[ x"$REPO_SUFFIX_LOCAL" == x"{{distribution}}/ci_templates_test_upstream" ]] ;
then
export FDO_REPO_SUFFIX=${DISTRO_VERSION} ;
export FDO_REPO_SUFFIX=${DISTRO}/${DISTRO_VERSION} ;
fi
# check if our image is already in the current registry
- skopeo inspect docker://$CI_REGISTRY_IMAGE/$DISTRO/$REPO_SUFFIX_LOCAL:$DISTRO_TAG > /dev/null && exit 0 || true
- skopeo inspect docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG > /dev/null && exit 0 || true
# check if our image is already in the upstream registry
- if [[ -z "$FDO_UPSTREAM_REPO" ]];
then
echo "WARNING! Variable \$FDO_UPSTREAM_REPO is undefined, cannot check for images" ;
else
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG > /dev/null && touch .upstream || true ;
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG > /dev/null && touch .upstream || true ;
fi
# copy the original image into the current project registry namespace
# we do 2 attempts with skopeo copy at most
- if [ -f .upstream ] ;
then
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
docker://$CI_REGISTRY_IMAGE/$DISTRO/$REPO_SUFFIX_LOCAL:$DISTRO_TAG ||
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG ||
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
docker://$CI_REGISTRY_IMAGE/$DISTRO/$REPO_SUFFIX_LOCAL:$DISTRO_TAG ;
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG ;
exit 0 ;
fi
......@@ -446,7 +447,7 @@
# The resulting image will be pushed to the local registry.
#
# If the repository suffix was specified, the image path is
# ``$CI_REGISTRY_IMAGE/{{distribution}}/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG``. The
# ``$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG``. The
# ``.fdo.suffixed_image@{{distribution}}`` template provides access to this image.
#
# If the repository suffix was **not** specified, the image path is
......@@ -554,6 +555,6 @@
# ``.fdo.distribution-image@{{distribution}}`` instead.
.fdo.suffixed_image@{{distribution}}:
extends: .fdo.{{distribution}}
image: $CI_REGISTRY_IMAGE/{{distribution}}/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
image: $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
variables:
FDO_DISTRIBUTION_IMAGE: $CI_REGISTRY_IMAGE/{{distribution}}/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
FDO_DISTRIBUTION_IMAGE: $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
......@@ -12,9 +12,10 @@
# - FDO_UPSTREAM_REPO: the upstream project on this gitlab instance
# where we might find the given tag (for example:
# `wayland/weston`)
# - FDO_REPO_SUFFIX: The repository name suffix after ".../alpine/".
# - FDO_REPO_SUFFIX: The repository name suffix.
# If this variable isn't defined,
# "$FDO_DISTRIBUTION_VERSION" is used for the suffix.
# "alpine/$FDO_DISTRIBUTION_VERSION" is used for
# the suffix.
# - FDO_DISTRIBUTION_TAG: tag to copy the image from the upstream registry. If the
# tag does not exist, create a new build and tag it
# - FDO_CACHE_DIR: A directory that needs to be mounted as `/cache` during
......@@ -22,7 +23,7 @@
# host, so that most users should not need this.
#
# The resulting image will be pushed in the local registry, under:
# $CI_REGISTRY_IMAGE/alpine/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
# $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
#
# Two flavors of templates are available:
# - `.fdo.container-build@alpine`: this will force rebuild a new container
......@@ -44,7 +45,7 @@
export DISTRO_EXEC=$FDO_DISTRIBUTION_EXEC
if [ x"$FDO_REPO_SUFFIX" == x"" ] ;
then
export FDO_REPO_SUFFIX=$DISTRO_VERSION
export FDO_REPO_SUFFIX=alpine/$DISTRO_VERSION
fi
export BUILDAH_RUN="buildah run --isolation chroot"
export BUILDAH_COMMIT="buildah commit --format docker"
......@@ -72,7 +73,7 @@
# The resulting image will be pushed to the local registry.
#
# If the repository suffix was specified, the image path is
# ``$CI_REGISTRY_IMAGE/alpine/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG``. The
# ``$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG``. The
# ``.fdo.suffixed_image@alpine`` template provides access to this image.
#
# If the repository suffix was **not** specified, the image path is
......@@ -93,7 +94,7 @@
echo $DISTRO tag missing;
exit 1;
fi
- echo Building $DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG from alpine:latest
- echo Building $FDO_REPO_SUFFIX:$DISTRO_TAG from alpine:latest
# initial set up: take the base image, update it and install the packages
- buildcntr=$(buildah from alpine:latest)
- buildmnt=$(buildah mount $buildcntr)
......@@ -138,7 +139,7 @@
# umount the container, not required, but, heh
- buildah unmount $buildcntr
# tag the current container
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
# clean up the working container
- buildah rm $buildcntr
......@@ -146,16 +147,16 @@
# There is a bug when pushing 2 tags in the same repo with the same base:
# this may fail. Just retry it after.
- export JOB_TAG="${DISTRO_TAG}-built-by-job-${CI_JOB_ID}"
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$JOB_TAG || true
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$JOB_TAG || true
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$JOB_TAG || true
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$JOB_TAG || true
# Push the final tag
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG || true
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG || true
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
###
# Builds a alpine container image for the ``arm64v8`` processor
......@@ -182,30 +183,30 @@
# project itself, we need to put a special case here to have a
# different image to pull if it already exists
- export REPO_SUFFIX_LOCAL=$FDO_REPO_SUFFIX
- if [[ x"$REPO_SUFFIX_LOCAL" == x"ci_templates_test_upstream" ]] ;
- if [[ x"$REPO_SUFFIX_LOCAL" == x"alpine/ci_templates_test_upstream" ]] ;
then
export FDO_REPO_SUFFIX=${DISTRO_VERSION} ;
export FDO_REPO_SUFFIX=${DISTRO}/${DISTRO_VERSION} ;
fi
# check if our image is already in the current registry
- skopeo inspect docker://$CI_REGISTRY_IMAGE/$DISTRO/$REPO_SUFFIX_LOCAL:$DISTRO_TAG > /dev/null && exit 0 || true
- skopeo inspect docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG > /dev/null && exit 0 || true
# check if our image is already in the upstream registry
- if [[ -z "$FDO_UPSTREAM_REPO" ]];
then
echo "WARNING! Variable \$FDO_UPSTREAM_REPO is undefined, cannot check for images" ;
else
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG > /dev/null && touch .upstream || true ;
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG > /dev/null && touch .upstream || true ;
fi
# copy the original image into the current project registry namespace
# we do 2 attempts with skopeo copy at most
- if [ -f .upstream ] ;
then
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
docker://$CI_REGISTRY_IMAGE/$DISTRO/$REPO_SUFFIX_LOCAL:$DISTRO_TAG ||
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG ||
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
docker://$CI_REGISTRY_IMAGE/$DISTRO/$REPO_SUFFIX_LOCAL:$DISTRO_TAG ;
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG ;
exit 0 ;
fi
......@@ -234,7 +235,7 @@
# The resulting image will be pushed to the local registry.
#
# If the repository suffix was specified, the image path is
# ``$CI_REGISTRY_IMAGE/alpine/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG``. The
# ``$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG``. The
# ``.fdo.suffixed_image@alpine`` template provides access to this image.
#
# If the repository suffix was **not** specified, the image path is
......@@ -311,6 +312,6 @@
# ``.fdo.distribution-image@alpine`` instead.
.fdo.suffixed_image@alpine:
extends: .fdo.alpine
image: $CI_REGISTRY_IMAGE/alpine/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
image: $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
variables:
FDO_DISTRIBUTION_IMAGE: $CI_REGISTRY_IMAGE/alpine/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
\ No newline at end of file
FDO_DISTRIBUTION_IMAGE: $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
\ No newline at end of file
......@@ -12,9 +12,10 @@
# - FDO_UPSTREAM_REPO: the upstream project on this gitlab instance
# where we might find the given tag (for example:
# `wayland/weston`)
# - FDO_REPO_SUFFIX: The repository name suffix after ".../arch/".
# - FDO_REPO_SUFFIX: The repository name suffix.
# If this variable isn't defined,
# "$FDO_DISTRIBUTION_VERSION" is used for the suffix.
# "arch/$FDO_DISTRIBUTION_VERSION" is used for
# the suffix.
# - FDO_DISTRIBUTION_TAG: tag to copy the image from the upstream registry. If the
# tag does not exist, create a new build and tag it
# - FDO_CACHE_DIR: A directory that needs to be mounted as `/cache` during
......@@ -22,7 +23,7 @@
# host, so that most users should not need this.
#
# The resulting image will be pushed in the local registry, under:
# $CI_REGISTRY_IMAGE/arch/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
# $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
#
# Two flavors of templates are available:
# - `.fdo.container-build@arch`: this will force rebuild a new container
......@@ -44,7 +45,7 @@
export DISTRO_EXEC=$FDO_DISTRIBUTION_EXEC
if [ x"$FDO_REPO_SUFFIX" == x"" ] ;
then
export FDO_REPO_SUFFIX=$DISTRO_VERSION
export FDO_REPO_SUFFIX=arch/$DISTRO_VERSION
fi
export BUILDAH_RUN="buildah run --isolation chroot"
export BUILDAH_COMMIT="buildah commit --format docker"
......@@ -72,7 +73,7 @@
# The resulting image will be pushed to the local registry.
#
# If the repository suffix was specified, the image path is
# ``$CI_REGISTRY_IMAGE/arch/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG``. The
# ``$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG``. The
# ``.fdo.suffixed_image@arch`` template provides access to this image.
#
# If the repository suffix was **not** specified, the image path is
......@@ -93,7 +94,7 @@
echo $DISTRO tag missing;
exit 1;
fi
- echo Building $DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG from archlinux/base
- echo Building $FDO_REPO_SUFFIX:$DISTRO_TAG from archlinux/base
# initial set up: take the base image, update it and install the packages
- buildcntr=$(buildah from archlinux/base)
- buildmnt=$(buildah mount $buildcntr)
......@@ -138,7 +139,7 @@
# umount the container, not required, but, heh
- buildah unmount $buildcntr
# tag the current container
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
# clean up the working container
- buildah rm $buildcntr
......@@ -146,16 +147,16 @@
# There is a bug when pushing 2 tags in the same repo with the same base:
# this may fail. Just retry it after.
- export JOB_TAG="${DISTRO_TAG}-built-by-job-${CI_JOB_ID}"
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$JOB_TAG || true
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$JOB_TAG || true
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$JOB_TAG || true
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$JOB_TAG || true
# Push the final tag
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG || true
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG || true
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
.fdo.before_script_ifnot_exists: &fdo_before_script_ifnot_exists
......@@ -169,30 +170,30 @@
# project itself, we need to put a special case here to have a
# different image to pull if it already exists
- export REPO_SUFFIX_LOCAL=$FDO_REPO_SUFFIX
- if [[ x"$REPO_SUFFIX_LOCAL" == x"ci_templates_test_upstream" ]] ;
- if [[ x"$REPO_SUFFIX_LOCAL" == x"arch/ci_templates_test_upstream" ]] ;
then
export FDO_REPO_SUFFIX=${DISTRO_VERSION} ;
export FDO_REPO_SUFFIX=${DISTRO}/${DISTRO_VERSION} ;
fi
# check if our image is already in the current registry
- skopeo inspect docker://$CI_REGISTRY_IMAGE/$DISTRO/$REPO_SUFFIX_LOCAL:$DISTRO_TAG > /dev/null && exit 0 || true
- skopeo inspect docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG > /dev/null && exit 0 || true
# check if our image is already in the upstream registry
- if [[ -z "$FDO_UPSTREAM_REPO" ]];
then
echo "WARNING! Variable \$FDO_UPSTREAM_REPO is undefined, cannot check for images" ;
else
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG > /dev/null && touch .upstream || true ;
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG > /dev/null && touch .upstream || true ;
fi
# copy the original image into the current project registry namespace
# we do 2 attempts with skopeo copy at most
- if [ -f .upstream ] ;
then
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
docker://$CI_REGISTRY_IMAGE/$DISTRO/$REPO_SUFFIX_LOCAL:$DISTRO_TAG ||
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG ||
skopeo copy --dest-creds $CI_REGISTRY_USER:$CI_REGISTRY_PASSWORD
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
docker://$CI_REGISTRY_IMAGE/$DISTRO/$REPO_SUFFIX_LOCAL:$DISTRO_TAG ;
docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG
docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG ;
exit 0 ;
fi
......@@ -221,7 +222,7 @@
# The resulting image will be pushed to the local registry.
#
# If the repository suffix was specified, the image path is
# ``$CI_REGISTRY_IMAGE/arch/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG``. The
# ``$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG``. The
# ``.fdo.suffixed_image@arch`` template provides access to this image.
#
# If the repository suffix was **not** specified, the image path is
......@@ -284,6 +285,6 @@
# ``.fdo.distribution-image@arch`` instead.
.fdo.suffixed_image@arch:
extends: .fdo.arch
image: $CI_REGISTRY_IMAGE/arch/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
image: $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
variables:
FDO_DISTRIBUTION_IMAGE: $CI_REGISTRY_IMAGE/arch/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
\ No newline at end of file
FDO_DISTRIBUTION_IMAGE: $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
\ No newline at end of file
......@@ -13,9 +13,10 @@
# - FDO_UPSTREAM_REPO: the upstream project on this gitlab instance
# where we might find the given tag (for example:
# `wayland/weston`)
# - FDO_REPO_SUFFIX: The repository name suffix after ".../centos/".
# - FDO_REPO_SUFFIX: The repository name suffix.
# If this variable isn't defined,
# "$FDO_DISTRIBUTION_VERSION" is used for the suffix.
# "centos/$FDO_DISTRIBUTION_VERSION" is used for
# the suffix.
# - FDO_DISTRIBUTION_TAG: tag to copy the image from the upstream registry. If the
# tag does not exist, create a new build and tag it
# - FDO_CACHE_DIR: A directory that needs to be mounted as `/cache` during
......@@ -23,7 +24,7 @@
# host, so that most users should not need this.
#
# The resulting image will be pushed in the local registry, under:
# $CI_REGISTRY_IMAGE/centos/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
# $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG
#
# Two flavors of templates are available:
# - `.fdo.container-build@centos`: this will force rebuild a new container
......@@ -44,7 +45,7 @@
export DISTRO_EXEC=$FDO_DISTRIBUTION_EXEC
if [ x"$FDO_REPO_SUFFIX" == x"" ] ;
then
export FDO_REPO_SUFFIX=$DISTRO_VERSION
export FDO_REPO_SUFFIX=centos/$DISTRO_VERSION
fi
export BUILDAH_RUN="buildah run --isolation chroot"
export BUILDAH_COMMIT="buildah commit --format docker"
......@@ -73,7 +74,7 @@
# The resulting image will be pushed to the local registry.
#
# If the repository suffix was specified, the image path is
# ``$CI_REGISTRY_IMAGE/centos/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG``. The
# ``$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$FDO_DISTRIBUTION_TAG``. The
# ``.fdo.suffixed_image@centos`` template provides access to this image.
#
# If the repository suffix was **not** specified, the image path is
......@@ -94,7 +95,7 @@
echo $DISTRO tag missing;
exit 1;
fi
- echo Building $DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG from $DISTRO:$DISTRO_VERSION
- echo Building $FDO_REPO_SUFFIX:$DISTRO_TAG from $DISTRO:$DISTRO_VERSION
# initial set up: take the base image, update it and install the packages
- buildcntr=$(buildah from $DISTRO:$DISTRO_VERSION)
- buildmnt=$(buildah mount $buildcntr)
......@@ -138,7 +139,7 @@
# umount the container, not required, but, heh
- buildah unmount $buildcntr
# tag the current container
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
- $BUILDAH_COMMIT $buildcntr $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
# clean up the working container
- buildah rm $buildcntr
......@@ -146,16 +147,16 @@
# There is a bug when pushing 2 tags in the same repo with the same base:
# this may fail. Just retry it after.
- export JOB_TAG="${DISTRO_TAG}-built-by-job-${CI_JOB_ID}"
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$JOB_TAG || true
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$JOB_TAG || true
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$JOB_TAG || true
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
$CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$JOB_TAG || true
# Push the final tag
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG || true
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG || true
- sleep 2
- podman push $CI_REGISTRY_IMAGE/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG
- podman push $CI_REGISTRY_IMAGE/$FDO_REPO_SUFFIX:$DISTRO_TAG
.fdo.before_script_ifnot_exists: &fdo_before_script_ifnot_exists
......@@ -169,30 +170,30 @@
# project itself, we need to put a special case here to have a
# different image to pull if it already exists
- export REPO_SUFFIX_LOCAL=$FDO_REPO_SUFFIX
- if [[ x"$REPO_SUFFIX_LOCAL" == x"ci_templates_test_upstream" ]] ;
- if [[ x"$REPO_SUFFIX_LOCAL" == x"centos/ci_templates_test_upstream" ]] ;
then
export FDO_REPO_SUFFIX=${DISTRO_VERSION} ;
export FDO_REPO_SUFFIX=${DISTRO}/${DISTRO_VERSION} ;
fi
# check if our image is already in the current registry
- skopeo inspect docker://$CI_REGISTRY_IMAGE/$DISTRO/$REPO_SUFFIX_LOCAL:$DISTRO_TAG > /dev/null && exit 0 || true
- skopeo inspect docker://$CI_REGISTRY_IMAGE/$REPO_SUFFIX_LOCAL:$DISTRO_TAG > /dev/null && exit 0 || true
# check if our image is already in the upstream registry
- if [[ -z "$FDO_UPSTREAM_REPO" ]];
then
echo "WARNING! Variable \$FDO_UPSTREAM_REPO is undefined, cannot check for images" ;
else
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$DISTRO/$FDO_REPO_SUFFIX:$DISTRO_TAG > /dev/null && touch .upstream || true ;
skopeo inspect docker://$CI_REGISTRY/$FDO_UPSTREAM_REPO/$FDO_REPO_SUFFIX:$DISTRO_TAG > /dev/null && touch .upstream || true ;
fi