aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantinos Smanis <konstantinos.smanis@gmail.com>2020-08-31 20:25:13 +0300
committerAlexys Jacob <ultrabug@gentoo.org>2020-09-04 16:48:55 +0200
commit8c87ce7de4d696ce595bf497aee42c8b80d8bd9f (patch)
treecad1c8756484ffc9ac2c8e4574ff98f43ece63b6
parentPush all stage3 images to the same Docker repo (diff)
downloaddocker-images-8c87ce7de4d696ce595bf497aee42c8b80d8bd9f.tar.gz
docker-images-8c87ce7de4d696ce595bf497aee42c8b80d8bd9f.tar.bz2
docker-images-8c87ce7de4d696ce595bf497aee42c8b80d8bd9f.zip
Deploy manifest lists along with per-arch images
Signed-off-by: Konstantinos Smanis <konstantinos.smanis@gmail.com> Signed-off-by: Alexys Jacob <ultrabug@gentoo.org>
-rw-r--r--.travis.yml16
-rwxr-xr-xbuild.sh1
-rwxr-xr-xdeploy.sh55
3 files changed, 63 insertions, 9 deletions
diff --git a/.travis.yml b/.travis.yml
index 7661939..754b3d7 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -5,7 +5,7 @@ env:
- ORG=gentoo
jobs:
- TARGET=portage
- - TARGET=stage3-amd64 LATEST=true
+ - TARGET=stage3-amd64
- TARGET=stage3-amd64-hardened
- TARGET=stage3-amd64-hardened-nomultilib
- TARGET=stage3-amd64-musl-hardened
@@ -55,10 +55,10 @@ after_success:
fi
docker run --rm "${ORG}/${TARGET/-/:}" emerge --info
fi
- # Push all built images to Docker Hub (cron daily task)
- - |
- if [[ "${TRAVIS_PULL_REQUEST_BRANCH:-${TRAVIS_BRANCH}}" == "master" && "${TRAVIS_EVENT_TYPE}" == "cron" ]]; then
- echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
- REPO="$(cut -d '-' -f 1 <<< ${TARGET})"
- docker push "${ORG}/${REPO}"
- fi
+deploy:
+ # Push to Docker Hub (daily cron job)
+ - provider: script
+ script: ./deploy.sh
+ on:
+ branch: master
+ condition: $TRAVIS_EVENT_TYPE = cron
diff --git a/build.sh b/build.sh
index 5fe7411..c3979a3 100755
--- a/build.sh
+++ b/build.sh
@@ -69,7 +69,6 @@ docker buildx build \
--build-arg SUFFIX="${SUFFIX}" \
--tag "${ORG}/${TARGET/-/:}" \
--tag "${ORG}/${TARGET/-/:}${VERSION_SUFFIX}" \
- ${LATEST:+--tag "${ORG}/${NAME}:latest"} \
--platform "linux/${DOCKER_ARCH}" \
--progress plain \
--load \
diff --git a/deploy.sh b/deploy.sh
new file mode 100755
index 0000000..b27d5ab
--- /dev/null
+++ b/deploy.sh
@@ -0,0 +1,55 @@
+#!/bin/bash
+
+if [[ -z "$TARGET" ]]; then
+ echo "TARGET environment variable must be set e.g. TARGET=stage3-amd64."
+ exit 1
+fi
+
+# Split the TARGET variable into three elements separated by hyphens
+IFS=- read -r NAME ARCH SUFFIX <<< "${TARGET}"
+
+# Push built images
+echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin
+docker push "${ORG}/${NAME}"
+
+if [[ "${TARGET}" != stage* ]]; then
+ echo "Done! No manifests to push for TARGET=${TARGET}."
+ exit 0
+fi
+
+VERSION=${VERSION:-$(date -u +%Y%m%d)}
+
+declare -A MANIFEST_ARCHES=(
+ [stage3:latest]="amd64;arm64;armv5tel;armv6j_hardfp;armv7a_hardfp;ppc64le;s390x;x86"
+ [stage3:hardened]="amd64;x86"
+ [stage3:hardened-nomultilib]="amd64"
+ [stage3:musl-hardened]="amd64"
+ [stage3:musl-vanilla]="amd64;x86"
+ [stage3:nomultilib]="amd64"
+ [stage3:systemd]="amd64;arm64;x86"
+ [stage3:uclibc-hardened]="amd64;x86"
+ [stage3:uclibc-vanilla]="amd64;x86"
+)
+
+# Latest manifests
+MANIFEST="${NAME}:${SUFFIX:-latest}"
+IFS=';' read -ra ARCHES <<< "${MANIFEST_ARCHES[${MANIFEST}]}"
+
+TAGS=()
+for ARCH in "${ARCHES[@]}"; do
+ TAGS+=("${ORG}/${NAME}:${ARCH}${SUFFIX:+-${SUFFIX}}")
+done
+
+docker manifest create "${ORG}/${MANIFEST}" "${TAGS[@]}"
+docker manifest push "${ORG}/${MANIFEST}"
+
+# Dated manifests
+MANIFEST="${NAME}:${SUFFIX:+${SUFFIX}-}${VERSION}"
+
+TAGS=()
+for ARCH in "${ARCHES[@]}"; do
+ TAGS+=("${ORG}/${NAME}:${ARCH}${SUFFIX:+-${SUFFIX}}-${VERSION}")
+done
+
+docker manifest create "${ORG}/${MANIFEST}" "${TAGS[@]}"
+docker manifest push "${ORG}/${MANIFEST}"