#!/usr/bin/env bash

BINARYDIR=${BINARYDIR:-.}
BUILDDIR=${BUILDDIR:-.}

IMAGEDIR=${BUILDDIR}/image-docker

mkdir -p ${IMAGEDIR}
cp ${BINARYDIR}/etcd ${BINARYDIR}/etcdctl ${IMAGEDIR}

cat <<DF > ${IMAGEDIR}/Dockerfile
FROM scratch
ADD etcd /
ADD etcdctl /
EXPOSE 4001 7001 2379 2380
ENTRYPOINT ["/etcd"]
DF

docker build -t quay.io/coreos/etcd:${1} ${IMAGEDIR}
