<commit_before>#!/usr/bin/env bash

set -o errexit -o nounset -o pipefail -o verbose

# This script build and push Docker image that has Mesos distro
# installed (based on CentOS).

CURRENT_DIR="$(cd "$(dirname "$0")"; pwd -P)"
SUPPORT_DIR="${CURRENT_DIR}/.."

: "${USERNAME:?"Environment variable 'USERNAME' must be set to the username of the 'Mesos DockerBot' Docker hub account."}"
: "${PASSWORD:?"Environment variable 'PASSWORD' must be set to the password of the 'Mesos DockerBot' Docker hub account."}"

DOCKER_IMAGE=${DOCKER_IMAGE:-"mesos/mesos-centos"}

MESOS_SHA=${MESOS_SHA:-$(git rev-parse HEAD)}
MESOS_TAG_OR_SHA=$(git describe --exact-match "${MESOS_SHA}" 2>/dev/null || echo "${MESOS_SHA}")
DOCKER_IMAGE_TAG="${MESOS_TAG_OR_SHA}"

echo "MESOS_SHA=${MESOS_SHA}"
echo "DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG}"

function cleanup {
  docker rmi "$(docker images -q "${DOCKER_IMAGE}:${DOCKER_IMAGE_TAG}")" || true
}

trap cleanup EXIT

CENTOS_DISTRO="7" \
DOCKER_IMAGE=${DOCKER_IMAGE} \
DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG} \
"${SUPPORT_DIR}/packaging/centos/build-docker-centos.sh"

DATE=$(date +%F)

docker tag "${DOCKER_IMAGE}:${DOCKER_IMAGE_TAG}" "${DOCKER_IMAGE}:${DATE}"
docker login -u "${USERNAME}" -p "${PASSWORD}"
docker push "${DOCKER_IMAGE}:${DOCKER_IMAGE_TAG}"
docker push "${DOCKER_IMAGE}:${DATE}"<commit_msg>Updated the way to generate tag for CentOS Docker.<commit_after>#!/usr/bin/env bash

set -o errexit -o nounset -o pipefail -o verbose

# This script build and push Docker image that has Mesos distro
# installed (based on CentOS).

CURRENT_DIR="$(cd "$(dirname "$0")"; pwd -P)"
SUPPORT_DIR="${CURRENT_DIR}/.."

: "${USERNAME:?"Environment variable 'USERNAME' must be set to the username of the 'Mesos DockerBot' Docker hub account."}"
: "${PASSWORD:?"Environment variable 'PASSWORD' must be set to the password of the 'Mesos DockerBot' Docker hub account."}"

DOCKER_IMAGE=${DOCKER_IMAGE:-"mesos/mesos-centos"}

MESOS_SHA=${MESOS_SHA:-$(git rev-parse HEAD)}
MESOS_TAG_OR_SHA=$(git describe --exact-match "${MESOS_SHA}" 2>/dev/null || echo "${MESOS_SHA}")
RELEASE_BRANCH=$(git branch --points-at HEAD -r | grep -E 'origin/[0-9]*\.[0-9]*\.x' | grep -E -o '[0-9]*\.[0-9]*\.x' || true)

if [ -z "${RELEASE_BRANCH}" ]; then
  RELEASE_BRANCH="master"
fi

DATE=$(date +%F)

if [[ "${MESOS_TAG_OR_SHA}" != "${MESOS_SHA}" ]]; then
  # HEAD is also a tag.
  DOCKER_IMAGE_TAG="${MESOS_TAG_OR_SHA}"
else
  DOCKER_IMAGE_TAG="${RELEASE_BRANCH}-${DATE}"
fi

echo "MESOS_SHA=${MESOS_SHA}"
echo "RELEASE_BRANCH=${RELEASE_BRANCH}"
echo "DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG}"

function cleanup {
  docker rmi "$(docker images -q "${DOCKER_IMAGE}:${DOCKER_IMAGE_TAG}")" || true
}

trap cleanup EXIT

CENTOS_DISTRO="7" \
DOCKER_IMAGE=${DOCKER_IMAGE} \
DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG} \
"${SUPPORT_DIR}/packaging/centos/build-docker-centos.sh"

docker login -u "${USERNAME}" -p "${PASSWORD}"
docker push "${DOCKER_IMAGE}:${DOCKER_IMAGE_TAG}"
{'fraction_non_alphanumeric': 0.17784552845528456, 'fraction_numerical': 0.0047425474254742545, 'mean_word_length': 5.931924882629108, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6064072', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1105, 'n_words': 261}