2020-03-04 20:23:02 +00:00
#!/usr/bin/env bash
#
# build zammads docker & docker-compose images
set -o errexit
set -o pipefail
DOCKER_REGISTRY = "index.docker.io"
REPO_ROOT = " $( git rev-parse --show-toplevel) "
ZAMMAD_VERSION = " $( git describe --tags | sed -e 's/-[a-z0-9]\{8,\}.*//g' ) "
# dockerhub auth
echo " ${ DOCKER_PASSWORD } " | docker login --username= " ${ DOCKER_USERNAME } " --password-stdin
# clone docker repo
2020-03-11 08:44:26 +00:00
DOCKER_REPOSITORY_CLONE_URL = " https://github.com/ ${ REPO_USER } / ${ DOCKER_GITHUB_REPOSITORY } "
echo " Cloning ${ DOCKER_REPOSITORY_CLONE_URL } "
git clone " ${ DOCKER_REPOSITORY_CLONE_URL } "
2020-03-04 20:23:02 +00:00
# enter dockerfile dir
2020-03-05 10:55:11 +00:00
cd " ${ REPO_ROOT } / ${ DOCKER_GITHUB_REPOSITORY } "
2020-03-04 20:23:02 +00:00
2020-03-05 18:49:58 +00:00
# shellcheck disable=SC2153
2020-03-04 20:23:02 +00:00
for DOCKER_IMAGE in ${ DOCKER_IMAGES } ; do
2020-03-06 12:10:59 +00:00
echo " Build Zammad Docker image ${ DOCKER_IMAGE } with version ${ ZAMMAD_VERSION } for DockerHubs ${ DOCKER_REGISTRY } / ${ REPO_USER } / ${ DOCKER_REPOSITORY } repo "
2020-03-04 20:23:02 +00:00
if [ " ${ DOCKER_REPOSITORY } " = = "zammad-docker-compose" ] ; then
2020-03-05 11:05:28 +00:00
docker build --pull --no-cache --build-arg BUILD_DATE = " $( date -u +'%Y-%m-%dT%H:%M:%SZ' ) " -t " ${ DOCKER_REGISTRY } / ${ REPO_USER } / ${ DOCKER_REPOSITORY } : ${ DOCKER_IMAGE } " -t " ${ DOCKER_REGISTRY } / ${ REPO_USER } / ${ DOCKER_REPOSITORY } : ${ DOCKER_IMAGE } -latest " -t " ${ DOCKER_REGISTRY } / ${ REPO_USER } / ${ DOCKER_REPOSITORY } : ${ DOCKER_IMAGE } - ${ ZAMMAD_VERSION } " -f " containers/ ${ DOCKER_IMAGE } /Dockerfile " .
2020-03-05 11:56:53 +00:00
docker push " ${ DOCKER_REGISTRY } / ${ REPO_USER } / ${ DOCKER_REPOSITORY } : ${ DOCKER_IMAGE } "
2020-03-05 11:05:28 +00:00
docker push " ${ DOCKER_REGISTRY } / ${ REPO_USER } / ${ DOCKER_REPOSITORY } : ${ DOCKER_IMAGE } -latest "
2020-03-05 11:56:53 +00:00
docker push " ${ DOCKER_REGISTRY } / ${ REPO_USER } / ${ DOCKER_REPOSITORY } : ${ DOCKER_IMAGE } - ${ ZAMMAD_VERSION } "
2020-03-04 20:23:02 +00:00
else
2020-03-05 11:05:28 +00:00
docker build --pull --no-cache --build-arg BUILD_DATE = " $( date -u +'%Y-%m-%dT%H:%M:%SZ' ) " -t " ${ DOCKER_REGISTRY } / ${ REPO_USER } / ${ DOCKER_REPOSITORY } :latest " -t " ${ DOCKER_REGISTRY } / ${ REPO_USER } / ${ DOCKER_REPOSITORY } : ${ ZAMMAD_VERSION } " .
2020-03-05 11:56:53 +00:00
docker push " ${ DOCKER_REGISTRY } / ${ REPO_USER } / ${ DOCKER_REPOSITORY } :latest "
docker push " ${ DOCKER_REGISTRY } / ${ REPO_USER } / ${ DOCKER_REPOSITORY } : ${ ZAMMAD_VERSION } "
2020-03-04 20:23:02 +00:00
fi
2020-03-05 11:05:28 +00:00
done