mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00

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>
45 lines
917 B
Bash
Executable File
45 lines
917 B
Bash
Executable File
#!/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"}
|
|
|
|
if [ -z ${BINARYDIR} ]; then
|
|
RELEASE="etcd-${1}"-`go env GOOS`-`go env GOARCH`
|
|
BINARYDIR="${RELEASE}"
|
|
TARFILE="${RELEASE}.tar.gz"
|
|
TARURL="https://github.com/coreos/etcd/releases/download/${1}/${TARFILE}"
|
|
curl -f -L -o ${TARFILE} ${TARURL}
|
|
if [ $? != 0 ]; then
|
|
echo "Failed to download ${TARURL}."
|
|
exit 1
|
|
fi
|
|
tar -zvxf ${TARFILE}
|
|
fi
|
|
|
|
if [ ${ARCH} != "amd64" ]; then
|
|
DOCKERFILE+=".${ARCH}"
|
|
VERSION+="-${ARCH}"
|
|
fi
|
|
|
|
BINARYDIR=${BINARYDIR:-.}
|
|
BUILDDIR=${BUILDDIR:-.}
|
|
|
|
IMAGEDIR=${BUILDDIR}/image-docker
|
|
|
|
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}:${VERSION} ${IMAGEDIR}
|