build-docker 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/usr/bin/env bash
  2. set -e
  3. if [ "$#" -ne 1 ]; then
  4. echo "Usage: $0 VERSION" >&2
  5. exit 1
  6. fi
  7. VERSION=${1}
  8. ARCH=$(go env GOARCH)
  9. DOCKERFILE="Dockerfile-release"
  10. if [ -z "${BINARYDIR}" ]; then
  11. RELEASE="etcd-${1}"-$(go env GOOS)-$(go env GOARCH)
  12. BINARYDIR="${RELEASE}"
  13. TARFILE="${RELEASE}.tar.gz"
  14. TARURL="https://github.com/coreos/etcd/releases/download/${1}/${TARFILE}"
  15. if ! curl -f -L -o "${TARFILE}" "${TARURL}" ; then
  16. echo "Failed to download ${TARURL}."
  17. exit 1
  18. fi
  19. tar -zvxf "${TARFILE}"
  20. fi
  21. if [ "${ARCH}" != "amd64" ]; then
  22. DOCKERFILE+=".${ARCH}"
  23. VERSION+="-${ARCH}"
  24. fi
  25. BINARYDIR=${BINARYDIR:-.}
  26. BUILDDIR=${BUILDDIR:-.}
  27. IMAGEDIR=${BUILDDIR}/image-docker
  28. mkdir -p "${IMAGEDIR}"/var/etcd
  29. mkdir -p "${IMAGEDIR}"/var/lib/etcd
  30. cp "${BINARYDIR}"/etcd "${BINARYDIR}"/etcdctl "${IMAGEDIR}"
  31. cat ./"${DOCKERFILE}" > "${IMAGEDIR}"/Dockerfile
  32. if [ -z "$TAG" ]; then
  33. docker build -t "gcr.io/etcd-development/etcd:${VERSION}" "${IMAGEDIR}"
  34. docker build -t "quay.io/coreos/etcd:${VERSION}" "${IMAGEDIR}"
  35. else
  36. docker build -t "${TAG}:${VERSION}" "${IMAGEDIR}"
  37. fi