Skip to content

Commit df40aa5

Browse files
authored
push multi-arch images to the dev registry (#890)
* push multi-arch images to the dev registry * cleam things up with a array of arches * missed setting a GOARCH * put quotes and {} everywhere * one of these isn't a variable
1 parent 1af329c commit df40aa5

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ IMG_NAMESPACE?=cloudnativelabs
88
GIT_COMMIT=$(shell git describe --tags --dirty)
99
GIT_BRANCH?=$(shell git rev-parse --abbrev-ref HEAD)
1010
IMG_TAG?=$(if $(IMG_TAG_PREFIX),$(IMG_TAG_PREFIX)-)$(if $(ARCH_TAG_PREFIX),$(ARCH_TAG_PREFIX)-)$(GIT_BRANCH)
11+
MANIFEST_TAG?=$(if $(IMG_TAG_PREFIX),$(IMG_TAG_PREFIX)-)$(GIT_BRANCH)
1112
RELEASE_TAG?=$(GOARCH)-$(shell build/get-git-tag.sh)
1213
REGISTRY?=$(if $(IMG_FQDN),$(IMG_FQDN)/$(IMG_NAMESPACE)/$(NAME),$(IMG_NAMESPACE)/$(NAME))
1314
REGISTRY_DEV?=$(REGISTRY)$(DEV_SUFFIX)
@@ -126,14 +127,21 @@ push: container docker-login ## Pushes a Docker container image to a registry.
126127
$(DOCKER) push "$(REGISTRY_DEV):$(IMG_TAG)"
127128
@echo Finished kube-router container image push.
128129

130+
push-manifest:
131+
@echo Starting kube-router manifest push.
132+
./manifest-tool push from-args \
133+
--platforms linux/amd64,linux/arm64,linux/arm,linux/s390x,linux/ppc64le \
134+
--template "$(REGISTRY_DEV):ARCH-$(MANIFEST_TAG)" \
135+
--target "$(REGISTRY_DEV):$(MANIFEST_TAG)"
136+
129137
push-release: push
130138
@echo Starting kube-router release container image push.
131139
@test -n "$(RELEASE_TAG)"
132140
$(DOCKER) tag "$(REGISTRY_DEV):$(IMG_TAG)" "$(REGISTRY):$(RELEASE_TAG)"
133141
$(DOCKER) push "$(REGISTRY)"
134142
@echo Finished kube-router release container image push.
135143

136-
push-manifest:
144+
push-manifest-release:
137145
@echo Starting kube-router manifest push.
138146
./manifest-tool push from-args \
139147
--platforms linux/amd64,linux/arm64,linux/arm,linux/s390x,linux/ppc64le \

build/travis-deploy.sh

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,45 +2,43 @@
22
set -o errexit
33
set -o pipefail
44

5+
GOARCHES=(amd64 arm64 arm s390x ppc64le)
6+
57
# Pull Request image tag format: PR00
68
if [ "${TRAVIS_EVENT_TYPE}" = "pull_request" ]; then
7-
PR_USER=$(echo "$TRAVIS_PULL_REQUEST_SLUG" | sed -e 's/\/.*//')
8-
if [ "$PR_USER" != "cloudnativelabs" ]; then
9-
echo "Not building/pushing PR $TRAVIS_PULL_REQUEST since only the cloudnativelabs user can access docker hub credentials"
9+
PR_USER=$(echo "${TRAVIS_PULL_REQUEST_SLUG}" | sed -e 's/\/.*//')
10+
if [ "${PR_USER}" != "cloudnativelabs" ]; then
11+
echo "Not building/pushing PR ${TRAVIS_PULL_REQUEST} since only the cloudnativelabs user can access docker hub credentials"
1012
exit 0
1113
fi
12-
echo "Building/pushing PR$TRAVIS_PULL_REQUEST from $PR_USER"
13-
make push IMG_TAG="PR$TRAVIS_PULL_REQUEST" GOARCH=amd64
14-
make clean IMG_TAG="PR$TRAVIS_PULL_REQUEST" GOARCH=amd64
15-
make push IMG_TAG="PR$TRAVIS_PULL_REQUEST" GOARCH=arm64
16-
make clean IMG_TAG="PR$TRAVIS_PULL_REQUEST" GOARCH=arm64
17-
make push IMG_TAG="PR$TRAVIS_PULL_REQUEST" GOARCH=arm
18-
make clean IMG_TAG="PR$TRAVIS_PULL_REQUEST" GOARCH=arm
19-
make push IMG_TAG="PR$TRAVIS_PULL_REQUEST" GOARCH=s390x
20-
make clean IMG_TAG="PR$TRAVIS_PULL_REQUEST" GOARCH=s390x
21-
make push IMG_TAG="PR$TRAVIS_PULL_REQUEST" GOARCH=ppc64le
22-
make clean IMG_TAG="PR$TRAVIS_PULL_REQUEST" GOARCH=ppc64le
14+
echo "Building/pushing PR${TRAVIS_PULL_REQUEST} from ${PR_USER}"
15+
for GOARCH in "${GOARCHES[@]}"; do
16+
make push IMG_TAG="${GOARCH}-PR${TRAVIS_PULL_REQUEST}" GOARCH="${GOARCH}"
17+
make clean IMG_TAG="${GOARCH}-PR${TRAVIS_PULL_REQUEST}" GOARCH="${GOARCH}"
18+
done
19+
echo "Pushing PR manifest on Travis"
20+
make push-manifest MANIFEST_TAG="PR${TRAVIS_PULL_REQUEST}"
2321
exit 0
2422
fi
2523

2624
# Release image tag format: v0.0.0 and latest
27-
if [ -n "$TRAVIS_TAG" ]; then
25+
if [ -n "${TRAVIS_TAG}" ]; then
2826
echo "Running Release build on Travis"
29-
make push-release RELEASE_TAG="amd64-$TRAVIS_TAG" GOARCH=amd64
30-
make clean RELEASE_TAG="amd64-$TRAVIS_TAG" GOARCH=amd64
31-
make push-release RELEASE_TAG="arm64-$TRAVIS_TAG" GOARCH=arm64
32-
make clean RELEASE_TAG="arm64-$TRAVIS_TAG" GOARCH=arm64
33-
make push-release RELEASE_TAG="arm-$TRAVIS_TAG" GOARCH=arm
34-
make clean RELEASE_TAG="arm-$TRAVIS_TAG" GOARCH=arm
35-
make push-release RELEASE_TAG="s390x-$TRAVIS_TAG" GOARCH=s390x
36-
make clean RELEASE_TAG="s390x-$TRAVIS_TAG" GOARCH=s390x
37-
make push-release RELEASE_TAG="ppc64le-$TRAVIS_TAG" GOARCH=ppc64le
38-
make clean RELEASE_TAG="ppc64le-$TRAVIS_TAG" GOARCH=ppc64le
39-
echo "Pushing manifest on Travis"
40-
make push-manifest RELEASE_TAG="$TRAVIS_TAG"
27+
for GOARCH in "${GOARCHES[@]}"; do
28+
make push-release RELEASE_TAG="${GOARCH}-${TRAVIS_TAG}" GOARCH="${GOARCH}"
29+
make clean RELEASE_TAG="${GOARCH}-${TRAVIS_TAG}" GOARCH="${GOARCH}"
30+
done
31+
echo "Pushing release manifest on Travis"
32+
make push-manifest-release RELEASE_TAG="${TRAVIS_TAG}"
4133
exit 0
4234
fi
4335

4436
# Push image tag format: COMMIT
4537
echo "Running push build on Travis"
46-
make push
38+
for GOARCH in "${GOARCHES[@]}"; do
39+
make push GOARCH="${GOARCH}"
40+
make clean GOARCH="${GOARCH}"
41+
done
42+
echo "Pushing manifest on Travis"
43+
make push-manifest
44+

0 commit comments

Comments
 (0)