unpoller_unpoller/init/docker/hooks/build

29 lines
882 B
Bash
Executable File

#!/bin/bash
# This always run local to the Dockerfile folder, so the path is ../..
set -e -o pipefail
# The Docker Cloud config must pass in the BUILDS env variable.
# See README.md (in this dir) and the screenshot for more info.
VERSION=$(git tag -l --merged | tail -n1 | tr -d v) # 1.2.3
DATE=$(date -u +%Y-%m-%dT%H:%M:%SZ)
COMMIT=$(git rev-parse --short HEAD)
ITERATION=$(git rev-list --count --all)
# Build each configured image from Docker Cloud.
for build in $BUILDS; do
# os:name:arch:variant
os=$(echo $build | cut -d: -f1)
name=$(echo $build | cut -d: -f2)
echo "Building Image ${IMAGE_NAME}_${os}_${name}"
docker build \
--build-arg "ARCH=${name}" \
--build-arg "BUILD_DATE=${DATE}" \
--build-arg "COMMIT=${COMMIT}" \
--build-arg "VERSION=${VERSION}-${ITERATION}" \
--tag "${IMAGE_NAME}_${os}_${name}" \
--file Dockerfile ../..
done