Skip to content

Commit

Permalink
build-docker: Updates for multi-arch release
Browse files Browse the repository at this point in the history
 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 <geoff@infradead.org>
  • Loading branch information
glevand committed Apr 14, 2017
1 parent 942491b commit 81cb0a1
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
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"]
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
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}"
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}

0 comments on commit 81cb0a1

Please sign in to comment.