Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: add multi-arch support in release binaries #7714

Merged
merged 5 commits into from
Apr 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Dockerfile-release.arm64
Original file line number Diff line number Diff line change
@@ -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"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be tagged as arm64 or aarch64? is there an official convention yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is totally open.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

4 changes: 2 additions & 2 deletions Dockerfile-release.ppc64le
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
3 changes: 2 additions & 1 deletion Documentation/v2/dev/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <release@coreos.com>` 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
Expand All @@ -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.
Expand Down
11 changes: 10 additions & 1 deletion scripts/build-aci
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -63,11 +70,13 @@ 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

# symlinks for backward-compatibility
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
1 change: 1 addition & 0 deletions scripts/build-binary
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function main {
TARGET_ARCHS=("amd64")

if [ ${GOOS} == "linux" ]; then
TARGET_ARCHS+=("arm64")
TARGET_ARCHS+=("ppc64le")
fi

Expand Down
12 changes: 8 additions & 4 deletions scripts/build-docker
Original file line number Diff line number Diff line change
@@ -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`
Expand All @@ -24,17 +27,18 @@ fi

if [ ${ARCH} != "amd64" ]; then
DOCKERFILE+=".${ARCH}"
TAG+="-${ARCH}"
VERSION+="-${ARCH}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the usual way to do multi arch? Won't this break ${TAG}:latest?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was following the presence set by flannel: https://quay.io/repository/coreos/flannel?tab=tags
I guess then we could have ${TAG}:latest-${arch}.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK

fi

BINARYDIR=${BINARYDIR:-.}
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}
16 changes: 11 additions & 5 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#
set -e

ARCH=$(go env GOARCH)
VERSION=$1
if [ -z "${VERSION}" ]; then
echo "Usage: ${0} VERSION" >> /dev/stderr
Expand All @@ -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}
Copy link
Contributor

@heyitsanthony heyitsanthony Apr 12, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was under the impression it's not possible to build docker images on a mismatched architecture. Does this work because the Dockerfile doesn't use RUN?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if the Dockerfile just uses ADD it works. If we want to use RUN, then I think we could setup QEMU user emulation to do that, but that is significantly more complicated and would add to the requirements of the host.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, great! glad it's possible to avoid that whole qemu mess

done
popd >/dev/null