aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantinos Smanis <konstantinos.smanis@gmail.com>2020-08-23 21:54:34 +0300
committerAlexys Jacob <ultrabug@gentoo.org>2020-09-03 22:34:00 +0200
commit2a77ebf7e7c02d43eb9dd385dc808efd87a54af0 (patch)
tree91983e0afdb79bbf9b2896715cc00f8f2edf2c33 /build.sh
parentUpdate Travis CI badge (diff)
downloaddocker-images-2a77ebf7e7c02d43eb9dd385dc808efd87a54af0.tar.gz
docker-images-2a77ebf7e7c02d43eb9dd385dc808efd87a54af0.tar.bz2
docker-images-2a77ebf7e7c02d43eb9dd385dc808efd87a54af0.zip
Add CI builds for all supported stage3 architectures
Build multiarch images using buildx [1] instead of modifying the image architecture post-creation with docker-copyedit. Although still experimental, buildx is the recommended way of building multi-platform images. All stage3 architectures that are supported by Docker [2] were added. Closes: #61 [1] https://docs.docker.com/buildx/working-with-buildx/#build-multi-platform-images [2] https://github.com/docker-library/official-images#architectures-other-than-amd64 Signed-off-by: Konstantinos Smanis <konstantinos.smanis@gmail.com> Closes: https://github.com/gentoo/gentoo-docker-images/pull/92 Signed-off-by: Alexys Jacob <ultrabug@gentoo.org>
Diffstat (limited to 'build.sh')
-rwxr-xr-xbuild.sh71
1 files changed, 45 insertions, 26 deletions
diff --git a/build.sh b/build.sh
index 10651cf..c0100d7 100755
--- a/build.sh
+++ b/build.sh
@@ -11,32 +11,45 @@ fi
# Split the TARGET variable into three elements separated by hyphens
IFS=- read -r NAME ARCH SUFFIX <<< "${TARGET}"
-DOCKER_ARCH="${ARCH}"
-
-# Ensure upstream directories for stage3-amd64-hardened+nomultilib work
-# unless we're building for musl targets (vanilla/hardened)
-if [[ "${SUFFIX}" != *musl* ]]; then
- SUFFIX=${SUFFIX/-/+}
-fi
VERSION=${VERSION:-$(date -u +%Y%m%d)}
ORG=${ORG:-gentoo}
-# x86 requires the i686 subfolder
-if [[ "${ARCH}" == "x86" ]]; then
- DOCKER_ARCH="386"
- MICROARCH="i686"
- BOOTSTRAP="multiarch/alpine:x86-v3.11"
-elif [[ "${ARCH}" = ppc* ]]; then
- MICROARCH="${ARCH}"
- ARCH=ppc
-elif [[ "${ARCH}" = arm* ]]; then
- DOCKER_ARCH=$(echo $ARCH | sed -e 's-\(v.\).*-/\1-g')
- MICROARCH="${ARCH}"
- ARCH=arm
-else
- MICROARCH="${ARCH}"
+case $ARCH in
+ "amd64" | "arm64")
+ DOCKER_ARCH="${ARCH}"
+ MICROARCH="${ARCH}"
+ ;;
+ "armv"*)
+ # armv6j_hardfp -> arm/v6
+ # armv7a_hardfp -> arm/v7
+ DOCKER_ARCH=$(echo "$ARCH" | sed -e 's#arm\(v.\).*#arm/\1#g')
+ MICROARCH="${ARCH}"
+ ARCH="arm"
+ ;;
+ "ppc64le")
+ DOCKER_ARCH="${ARCH}"
+ MICROARCH="${ARCH}"
+ ARCH="ppc"
+ ;;
+ "s390x")
+ DOCKER_ARCH="${ARCH}"
+ MICROARCH="${ARCH}"
+ ARCH="s390"
+ ;;
+ "x86")
+ DOCKER_ARCH="386"
+ MICROARCH="i686"
+ ;;
+ *) # portage
+ DOCKER_ARCH="amd64"
+ ;;
+esac
+
+# Handle targets with special characters in the suffix
+if [[ "${TARGET}" == "stage3-amd64-hardened-nomultilib" ]]; then
+ SUFFIX="hardened+nomultilib"
fi
# Prefix the suffix with a hyphen to make sure the URL works
@@ -44,8 +57,14 @@ if [[ -n "${SUFFIX}" ]]; then
SUFFIX="-${SUFFIX}"
fi
-set -x
-docker build --build-arg ARCH="${ARCH}" --build-arg MICROARCH="${MICROARCH}" --build-arg BOOTSTRAP="${BOOTSTRAP}" --build-arg SUFFIX="${SUFFIX}" -t "${ORG}/${TARGET}:${VERSION}" -f "${NAME}.Dockerfile" .
-docker-copyedit/docker-copyedit.py FROM "${ORG}/${TARGET}:${VERSION}" INTO "${ORG}/${TARGET}:${VERSION}" -vv \
- set arch ${DOCKER_ARCH}
-docker tag "${ORG}/${TARGET}:${VERSION}" "${ORG}/${TARGET}:latest"
+docker buildx build \
+ --file "${NAME}.Dockerfile" \
+ --build-arg ARCH="${ARCH}" \
+ --build-arg MICROARCH="${MICROARCH}" \
+ --build-arg SUFFIX="${SUFFIX}" \
+ --tag "${ORG}/${TARGET}:latest" \
+ --tag "${ORG}/${TARGET}:${VERSION}" \
+ --platform "linux/${DOCKER_ARCH}" \
+ --progress plain \
+ --load \
+ .