From fb6287240fd53b3ab2491f20d55993844af92cd7 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Fri, 21 Apr 2017 10:04:41 -0700 Subject: [PATCH 1/5] build-binary: Add arm64 Signed-off-by: Geoff Levand --- scripts/build-binary | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/build-binary b/scripts/build-binary index 18646c75f83..3b4b763dee0 100755 --- a/scripts/build-binary +++ b/scripts/build-binary @@ -62,6 +62,7 @@ function main { TARGET_ARCHS=("amd64") if [ ${GOOS} == "linux" ]; then + TARGET_ARCHS+=("arm64") TARGET_ARCHS+=("ppc64le") fi From 8309ca92d7353c956d7ea07a14486ec4043fc384 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Fri, 21 Apr 2017 10:04:41 -0700 Subject: [PATCH 2/5] build-aci: Add multi arch support Uses GOARCH to build for a targeted arch. Usage: GOARCH=... BINARYDIR=... BUILDDIR=... ./scripts/build-aci version Signed-off-by: Geoff Levand --- scripts/build-aci | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/scripts/build-aci b/scripts/build-aci index f13e9a7a56f..f30a0af3206 100755 --- a/scripts/build-aci +++ b/scripts/build-aci @@ -11,6 +11,13 @@ ACBUILD=${ACBUILD:-acbuild} VERSION=$1 +go2aci() { + case "${1}" in + "arm64") echo "aarch64";; + *) echo "${1}";; + esac +} + if ! command -v $ACBUILD >/dev/null; then echo "acbuild ($ACBUILD) is not executable" exit 1 @@ -63,6 +70,8 @@ acbuild --debug port add peer tcp 2380 acbuild --debug copy "$TMPHOSTS" /etc/hosts +acbuild --debug label add arch $(go2aci ${GOARCH}) + # mkdir default data-dir mkdir -p .acbuild/currentaci/rootfs/var/lib/etcd @@ -70,4 +79,4 @@ mkdir -p .acbuild/currentaci/rootfs/var/lib/etcd ln -s ./usr/local/bin/etcd .acbuild/currentaci/rootfs/etcd ln -s ./usr/local/bin/etcdctl .acbuild/currentaci/rootfs/etcdctl -acbuild --debug write --overwrite $BUILDDIR/etcd-${1}-linux-amd64.aci +acbuild --debug write --overwrite $BUILDDIR/etcd-${1}-linux-${GOARCH}.aci From 0c8988aa078f40d079f96d0824a61de3d3838f04 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Fri, 21 Apr 2017 10:04:41 -0700 Subject: [PATCH 3/5] build-docker: Updates for multi-arch release o Set -e to abort script if a command fails. o Allow custom docker 'TAG' from the environment. o Move arch suffix to version to allow all images to be put into a single repository. o Enable cross builds. When doing cross builds where the host and target architectures are different 'RUN mkdir' will fail since the target container cannot be run on the host. To work around this, create the directories in build-docker, then use ADD in the Dockerfile. o Add Dockerfile-release.arm64 Signed-off-by: Geoff Levand --- Dockerfile-release.arm64 | 11 +++++++++++ Dockerfile-release.ppc64le | 4 ++-- scripts/build-docker | 12 ++++++++---- 3 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 Dockerfile-release.arm64 diff --git a/Dockerfile-release.arm64 b/Dockerfile-release.arm64 new file mode 100644 index 00000000000..d8816e58d22 --- /dev/null +++ b/Dockerfile-release.arm64 @@ -0,0 +1,11 @@ +FROM aarch64/ubuntu:16.04 + +ADD etcd /usr/local/bin/ +ADD etcdctl /usr/local/bin/ +ADD var/etcd /var/etcd +ADD var/lib/etcd /var/lib/etcd + +EXPOSE 2379 2380 + +# Define default command. +CMD ["/usr/local/bin/etcd"] diff --git a/Dockerfile-release.ppc64le b/Dockerfile-release.ppc64le index 06365c8bc99..2fb02c412cb 100644 --- a/Dockerfile-release.ppc64le +++ b/Dockerfile-release.ppc64le @@ -2,8 +2,8 @@ FROM ppc64le/ubuntu:16.04 ADD etcd /usr/local/bin/ ADD etcdctl /usr/local/bin/ -RUN mkdir -p /var/etcd/ -RUN mkdir -p /var/lib/etcd/ +ADD var/etcd /var/etcd +ADD var/lib/etcd /var/lib/etcd EXPOSE 2379 2380 diff --git a/scripts/build-docker b/scripts/build-docker index 44641322f79..5c01321361d 100755 --- a/scripts/build-docker +++ b/scripts/build-docker @@ -1,13 +1,16 @@ #!/usr/bin/env bash +set -e + if [ "$#" -ne 1 ]; then echo "Usage: $0 VERSION" >&2 exit 1 fi +VERSION=${1} ARCH=$(go env GOARCH) DOCKERFILE="Dockerfile-release" -TAG="quay.io/coreos/etcd" +: ${TAG:="quay.io/coreos/etcd"} if [ -z ${BINARYDIR} ]; then RELEASE="etcd-${1}"-`go env GOOS`-`go env GOARCH` @@ -24,7 +27,7 @@ fi if [ ${ARCH} != "amd64" ]; then DOCKERFILE+=".${ARCH}" - TAG+="-${ARCH}" + VERSION+="-${ARCH}" fi BINARYDIR=${BINARYDIR:-.} @@ -32,9 +35,10 @@ BUILDDIR=${BUILDDIR:-.} IMAGEDIR=${BUILDDIR}/image-docker -mkdir -p ${IMAGEDIR} +mkdir -p ${IMAGEDIR}/var/etcd +mkdir -p ${IMAGEDIR}/var/lib/etcd cp ${BINARYDIR}/etcd ${BINARYDIR}/etcdctl ${IMAGEDIR} cat ./${DOCKERFILE} > ${IMAGEDIR}/Dockerfile -docker build -t ${TAG}:${1} ${IMAGEDIR} +docker build -t ${TAG}:${VERSION} ${IMAGEDIR} From 07c07cea253589b6272913912ab92e901e031d96 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Fri, 21 Apr 2017 10:04:41 -0700 Subject: [PATCH 4/5] release: Add multi arch support Signed-off-by: Geoff Levand --- scripts/release.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/release.sh b/scripts/release.sh index 67b6661ea26..d6c6edbf947 100755 --- a/scripts/release.sh +++ b/scripts/release.sh @@ -5,7 +5,6 @@ # set -e -ARCH=$(go env GOARCH) VERSION=$1 if [ -z "${VERSION}" ]; then echo "Usage: ${0} VERSION" >> /dev/stderr @@ -27,8 +26,15 @@ ETCD_ROOT=$(dirname "${BASH_SOURCE}")/.. pushd ${ETCD_ROOT} >/dev/null echo Building etcd binary... ./scripts/build-binary ${VERSION} - echo Building aci image... - BINARYDIR=release/etcd-${VERSION}-linux-amd64 BUILDDIR=release ./scripts/build-aci ${VERSION} - echo Building docker image... - BINARYDIR=release/etcd-${VERSION}-linux-${ARCH} BUILDDIR=release ./scripts/build-docker ${VERSION} + + # ppc64le not yet supported by acbuild. + for TARGET_ARCH in "amd64" "arm64"; do + echo Building ${TARGET_ARCH} aci image... + GOARCH=${TARGET_ARCH} BINARYDIR=release/etcd-${VERSION}-linux-${TARGET_ARCH} BUILDDIR=release ./scripts/build-aci ${VERSION} + done + + for TARGET_ARCH in "amd64" "arm64" "ppc64le"; do + echo Building ${TARGET_ARCH} docker image... + GOARCH=${TARGET_ARCH} BINARYDIR=release/etcd-${VERSION}-linux-${TARGET_ARCH} BUILDDIR=release ./scripts/build-docker ${VERSION} + done popd >/dev/null From bf987185a9d9d0919b27f5c031622fe11e5e7ecb Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Fri, 21 Apr 2017 10:04:41 -0700 Subject: [PATCH 5/5] release.md: Update for multi arch release Signed-off-by: Geoff Levand --- Documentation/v2/dev/release.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Documentation/v2/dev/release.md b/Documentation/v2/dev/release.md index 15423716087..6db86a2418d 100644 --- a/Documentation/v2/dev/release.md +++ b/Documentation/v2/dev/release.md @@ -70,7 +70,7 @@ cd release # personal GPG is okay for now for i in etcd-*{.zip,.tar.gz}; do gpg --sign ${i}; done # use `CoreOS ACI Builder ` secret key -gpg -u 88182190 -a --output etcd-${VERSION}-linux-amd64.aci.asc --detach-sig etcd-${VERSION}-linux-amd64.aci +for aci in etcd-${VERSION}.*.aci; do gpg -u 88182190 -a --output ${aci}.asc --detach-sig ${aci}; done ``` ## Publish Release Page in GitHub @@ -88,6 +88,7 @@ gpg -u 88182190 -a --output etcd-${VERSION}-linux-amd64.aci.asc --detach-sig etc ``` docker login quay.io docker push quay.io/coreos/etcd:${VERSION} +docker push quay.io/coreos/etcd:${VERSION}-${arch} ``` - Add `latest` tag to the new image on [quay.io](https://quay.io/repository/coreos/etcd?tag=latest&tab=tags) if this is a stable release.