aboutsummaryrefslogtreecommitdiffstats
path: root/docker_push_manifest.sh
diff options
context:
space:
mode:
authorPaul Vaduva <Paul.Vaduva@enea.com>2019-06-27 18:00:57 +0200
committerCristina Pauna <cristina.pauna@enea.com>2019-09-05 22:14:56 +0300
commit4da9d4476fe968d3b915f7ca28b22bb322899614 (patch)
tree4db52be328d455f2244395f76f387f183c4ffc39 /docker_push_manifest.sh
parent1f89af3b9916cd2b0198aa3a9491946f33c3f7cc (diff)
Multiplatform support for policy
Add multiplatfrom support for policy-base and policy-common docker images: - the pom.xml files are modified to push and pull from dockerhub instead of nexus repository (as nexus lacks support for manifest list) - for each image that is built with maven, an arch suffix is added to the tag. The currently supported architectures are amd64 and arm64. - the creation of the timestamped tag is moved from the pom.xml files to the docker_push_manifest.sh script - for each image built via the Jenkins CI jobs, the docker_push_manifest.sh is called. The script pushes a manifest list for each tag, plus it creates the timestamp tags for SNAPSHOT or STAGING images, depending on what job called the script (merge job, or stag job) For using the images, the name of the manifest list is to be used (which is the same as the current images in nexus) Issue-ID: POLICY-1997 Change-Id: If54e7ee6ac432a999844d3584e146a90e2247323 Signed-off-by: Paul Vaduva <Paul.Vaduva@enea.com> Signed-off-by: Cristina Pauna <cristina.pauna@enea.com> Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
Diffstat (limited to 'docker_push_manifest.sh')
-rwxr-xr-xdocker_push_manifest.sh59
1 files changed, 59 insertions, 0 deletions
diff --git a/docker_push_manifest.sh b/docker_push_manifest.sh
new file mode 100755
index 00000000..7e2ba852
--- /dev/null
+++ b/docker_push_manifest.sh
@@ -0,0 +1,59 @@
+#!/bin/bash -ex
+# ============LICENSE_START=======================================================
+# Copyright (C) 2019 ENEA AB. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+
+# This script creates the multi-arch manifest for the docker images
+
+# shellcheck source=/dev/null
+source version.properties
+IMAGES="onap/policy-base-alpine onap/policy-common-alpine"
+ARCHES="amd64 arm64"
+TIMESTAMP=$(date -u +"%Y%m%d%H%M%S")
+MT_RELEASE='v0.9.0'
+
+# Download the manifest tool based on the host's architecture
+HOST_ARCH='amd64'
+if [ "$(uname -m)" == 'aarch64' ]; then
+ HOST_ARCH='arm64'
+fi
+wget https://github.com/estesp/manifest-tool/releases/download/${MT_RELEASE}/manifest-tool-linux-${HOST_ARCH} -O ./manifest-tool
+chmod u+x manifest-tool
+
+# Tag the images and push the manifest (do not fail if some prerequisite tags are not yet present)
+set +e
+for image in ${IMAGES}; do
+ # always (re)create both SNAPSHOT and STAGING tags to make sure everything is up to date
+ TAGS="latest ${release_version} ${release_version}-SNAPSHOT ${release_version}-SNAPSHOT-latest ${release_version}-STAGING-latest"
+ for tag in ${TAGS}; do
+ ./manifest-tool push from-args \
+ --ignore-missing \
+ --platforms "linux/${ARCHES// /,linux/}" \
+ --template "${image}:${tag}-ARCH" \
+ --target "${image}:${tag}"
+ done
+
+ # Create timestamped multiarch tag; if the script is ran from the merge
+ # job then add the SNAPSHOT suffix
+ [[ "${PARENT_JOB_NAME}" =~ merge ]] && snapshot_suffix="SNAPSHOT-"
+
+ ./manifest-tool push from-args \
+ --ignore-missing \
+ --platforms "linux/${ARCHES// /,linux/}" \
+ --template "${image}:${release_version}-${snapshot_suffix:-}ARCH" \
+ --target "${image}:${release_version}-${snapshot_suffix:-}${TIMESTAMP}"
+done