1 |
commit: 8c87ce7de4d696ce595bf497aee42c8b80d8bd9f |
2 |
Author: Konstantinos Smanis <konstantinos.smanis <AT> gmail <DOT> com> |
3 |
AuthorDate: Mon Aug 31 17:25:13 2020 +0000 |
4 |
Commit: Alexys Jacob <ultrabug <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Sep 4 14:48:55 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/docker-images.git/commit/?id=8c87ce7d |
7 |
|
8 |
Deploy manifest lists along with per-arch images |
9 |
|
10 |
Signed-off-by: Konstantinos Smanis <konstantinos.smanis <AT> gmail.com> |
11 |
Signed-off-by: Alexys Jacob <ultrabug <AT> gentoo.org> |
12 |
|
13 |
.travis.yml | 16 ++++++++-------- |
14 |
build.sh | 1 - |
15 |
deploy.sh | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
16 |
3 files changed, 63 insertions(+), 9 deletions(-) |
17 |
|
18 |
diff --git a/.travis.yml b/.travis.yml |
19 |
index 7661939..754b3d7 100644 |
20 |
--- a/.travis.yml |
21 |
+++ b/.travis.yml |
22 |
@@ -5,7 +5,7 @@ env: |
23 |
- ORG=gentoo |
24 |
jobs: |
25 |
- TARGET=portage |
26 |
- - TARGET=stage3-amd64 LATEST=true |
27 |
+ - TARGET=stage3-amd64 |
28 |
- TARGET=stage3-amd64-hardened |
29 |
- TARGET=stage3-amd64-hardened-nomultilib |
30 |
- TARGET=stage3-amd64-musl-hardened |
31 |
@@ -55,10 +55,10 @@ after_success: |
32 |
fi |
33 |
docker run --rm "${ORG}/${TARGET/-/:}" emerge --info |
34 |
fi |
35 |
- # Push all built images to Docker Hub (cron daily task) |
36 |
- - | |
37 |
- if [[ "${TRAVIS_PULL_REQUEST_BRANCH:-${TRAVIS_BRANCH}}" == "master" && "${TRAVIS_EVENT_TYPE}" == "cron" ]]; then |
38 |
- echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin |
39 |
- REPO="$(cut -d '-' -f 1 <<< ${TARGET})" |
40 |
- docker push "${ORG}/${REPO}" |
41 |
- fi |
42 |
+deploy: |
43 |
+ # Push to Docker Hub (daily cron job) |
44 |
+ - provider: script |
45 |
+ script: ./deploy.sh |
46 |
+ on: |
47 |
+ branch: master |
48 |
+ condition: $TRAVIS_EVENT_TYPE = cron |
49 |
|
50 |
diff --git a/build.sh b/build.sh |
51 |
index 5fe7411..c3979a3 100755 |
52 |
--- a/build.sh |
53 |
+++ b/build.sh |
54 |
@@ -69,7 +69,6 @@ docker buildx build \ |
55 |
--build-arg SUFFIX="${SUFFIX}" \ |
56 |
--tag "${ORG}/${TARGET/-/:}" \ |
57 |
--tag "${ORG}/${TARGET/-/:}${VERSION_SUFFIX}" \ |
58 |
- ${LATEST:+--tag "${ORG}/${NAME}:latest"} \ |
59 |
--platform "linux/${DOCKER_ARCH}" \ |
60 |
--progress plain \ |
61 |
--load \ |
62 |
|
63 |
diff --git a/deploy.sh b/deploy.sh |
64 |
new file mode 100755 |
65 |
index 0000000..b27d5ab |
66 |
--- /dev/null |
67 |
+++ b/deploy.sh |
68 |
@@ -0,0 +1,55 @@ |
69 |
+#!/bin/bash |
70 |
+ |
71 |
+if [[ -z "$TARGET" ]]; then |
72 |
+ echo "TARGET environment variable must be set e.g. TARGET=stage3-amd64." |
73 |
+ exit 1 |
74 |
+fi |
75 |
+ |
76 |
+# Split the TARGET variable into three elements separated by hyphens |
77 |
+IFS=- read -r NAME ARCH SUFFIX <<< "${TARGET}" |
78 |
+ |
79 |
+# Push built images |
80 |
+echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin |
81 |
+docker push "${ORG}/${NAME}" |
82 |
+ |
83 |
+if [[ "${TARGET}" != stage* ]]; then |
84 |
+ echo "Done! No manifests to push for TARGET=${TARGET}." |
85 |
+ exit 0 |
86 |
+fi |
87 |
+ |
88 |
+VERSION=${VERSION:-$(date -u +%Y%m%d)} |
89 |
+ |
90 |
+declare -A MANIFEST_ARCHES=( |
91 |
+ [stage3:latest]="amd64;arm64;armv5tel;armv6j_hardfp;armv7a_hardfp;ppc64le;s390x;x86" |
92 |
+ [stage3:hardened]="amd64;x86" |
93 |
+ [stage3:hardened-nomultilib]="amd64" |
94 |
+ [stage3:musl-hardened]="amd64" |
95 |
+ [stage3:musl-vanilla]="amd64;x86" |
96 |
+ [stage3:nomultilib]="amd64" |
97 |
+ [stage3:systemd]="amd64;arm64;x86" |
98 |
+ [stage3:uclibc-hardened]="amd64;x86" |
99 |
+ [stage3:uclibc-vanilla]="amd64;x86" |
100 |
+) |
101 |
+ |
102 |
+# Latest manifests |
103 |
+MANIFEST="${NAME}:${SUFFIX:-latest}" |
104 |
+IFS=';' read -ra ARCHES <<< "${MANIFEST_ARCHES[${MANIFEST}]}" |
105 |
+ |
106 |
+TAGS=() |
107 |
+for ARCH in "${ARCHES[@]}"; do |
108 |
+ TAGS+=("${ORG}/${NAME}:${ARCH}${SUFFIX:+-${SUFFIX}}") |
109 |
+done |
110 |
+ |
111 |
+docker manifest create "${ORG}/${MANIFEST}" "${TAGS[@]}" |
112 |
+docker manifest push "${ORG}/${MANIFEST}" |
113 |
+ |
114 |
+# Dated manifests |
115 |
+MANIFEST="${NAME}:${SUFFIX:+${SUFFIX}-}${VERSION}" |
116 |
+ |
117 |
+TAGS=() |
118 |
+for ARCH in "${ARCHES[@]}"; do |
119 |
+ TAGS+=("${ORG}/${NAME}:${ARCH}${SUFFIX:+-${SUFFIX}}-${VERSION}") |
120 |
+done |
121 |
+ |
122 |
+docker manifest create "${ORG}/${MANIFEST}" "${TAGS[@]}" |
123 |
+docker manifest push "${ORG}/${MANIFEST}" |