forked from willfarrell/docker-autoheal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
36 lines (29 loc) · 1.28 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/sh
REPO=${1}
DOCKER_USERNAME=${2}
DOCKER_PASSWORD=${3}
DOCKER_REGESTRY=${4}
declare -A ARCH_MAP
ARCH_MAP[x86_64]=x86_64
ARCH_MAP[armhf]=arm
ARCH_MAP[arm64]=arm64
docker run --rm --privileged multiarch/qemu-user-static:register --reset
echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin
echo "Building docker images"
for i in "${!ARCH_MAP[@]}"; do
echo "################################################################################"
echo "Building and pushing: ${REPO}-${ARCH_MAP[$i]}:latest "
echo "################################################################################"
docker build --build-arg arch=${i} -t ${REPO}-${ARCH_MAP[$i]}:latest .;
docker push ${REPO}-${ARCH_MAP[$i]}:latest;
done;
MANIFESTS=""
for arch in "${ARCH_MAP[@]}"; do MANIFESTS="${MANIFESTS} ${REPO}-${arch}:latest"; done
echo "################################################################################"
echo "Building and pushing: ${REPO}-${ARCH_MAP[$i]}:latest "
echo "################################################################################"
docker manifest create ${REPO}:latest ${MANIFESTS};
for arch in "${ARCH_MAP[@]}"; do
docker manifest annotate --os linux --arch ${arch} ${REPO}:latest ${REPO}-${arch}:latest;
done;
docker manifest push ${REPO}:latest