zammad-docker-compose/hooks/build
2019-02-15 16:52:40 +01:00

38 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
#
# build hook for dockerhubs autobuild feature
#
set -e
. "hooks/config"
#shellcheck disable=SC2153
for DOCKER_IMAGE in ${DOCKER_IMAGES}; do
if [ "${TRAVIS}" == 'true' ] || [ "${CIRCLECI}" == 'true' ]; then
if [ -n "${ZAMMAD_VERSION}" ]; then
DOCKER_TAG="-t ${DOCKER_REGISTRY}/${GITHUB_USERNAME}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}-${ZAMMAD_VERSION}"
else
ZAMMAD_VERSION="latest"
fi
echo "Build Zammad Docker image ${DOCKER_IMAGE} with version ${ZAMMAD_VERSION} for DockerHubs ${DOCKER_REGISTRY}/${GITHUB_USERNAME}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE} repo"
docker build --pull --no-cache --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" -t ${DOCKER_REGISTRY}/${GITHUB_USERNAME}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE} -t ${DOCKER_REGISTRY}/${GITHUB_USERNAME}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}-latest ${DOCKER_TAG} -f containers/${DOCKER_IMAGE}/Dockerfile .
docker push ${DOCKER_REGISTRY}/${GITHUB_USERNAME}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}
docker push ${DOCKER_REGISTRY}/${GITHUB_USERNAME}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}-latest
if [ "${ZAMMAD_VERSION}" != "latest" ]; then
docker push ${DOCKER_REGISTRY}/${GITHUB_USERNAME}/${DOCKER_REPOSITORY}:${DOCKER_IMAGE}-${ZAMMAD_VERSION}
fi
else
echo "Build Zammad Docker image ${DOCKER_IMAGE} for DockerHubs ${DOCKER_REPO}:${DOCKER_IMAGE} repo"
docker build --pull --no-cache --build-arg BUILD_DATE="$(date -u +'%Y-%m-%dT%H:%M:%SZ')" -t "${DOCKER_REPO}:${DOCKER_IMAGE}" -f containers/"${DOCKER_IMAGE}"/Dockerfile .
docker push ${DOCKER_REPO}:${DOCKER_IMAGE}
fi
done