1
0
intel-media-ffmpeg/scripts/build-image.sh
James Ketrenos 363f40de52 Refactored scripts/* and .gitlab-ci.yml
Fix #6: Define TAG in .gitlab-ci.yml and update scripts to defer to it.

renamed:    scripts/push-test-image.sh -> scripts/push-image.sh
renamed:    scripts/test-tag.sh -> scripts/test-image.sh

Refactored some of the scripts/* so they are generic and not tied to CI usages.

Added error checking and output to push-rolling-image.sh and remove-tag.sh

Added scripts/trigger.sh to auto-trigger builds.

Signed-off-by: James Ketrenos <james.p.ketrenos@intel.com>
2019-12-17 21:04:52 -08:00

78 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# Bring in the variables from SOLUTION file, supporting
# nested substitution
. SOLUTION
. MANIFEST
VARS=($(sed -nE "s,(^[^#][^=]*).*$,\1,pg" SOLUTION))
VARS+=($(sed -nE "s,(^[^#][^=]*).*$,\1,pg" MANIFEST))
for var in ${VARS[@]}; do
export ${var}
done
RELEASE_INFO=${RELEASE_INFO:-N/A}
[[ "${RELEASE_INFO}" == "N/A" ]] && {
TAG=${TAG:-test-build-${OS_DISTRO}-${PACKAGE_STREAM}-$(date +%Y%m%d)}
} || {
TAG=${TAG:-test-${OS_DISTRO}-${PACKAGE_STREAM}-${RELEASE_INFO}}
}
case "${OS_DISTRO}" in
rhel)
SOLUTION_SUFFIX=".rhel-8.0"
;;
ubuntu)
SOLUTION_SUFFIX=""
;;
*)
SOLUTION_SUFFIX=".${OS_DISTRO}-${OS_RELEASE}"
[[ -d "templates/${OS_DISTRO}" ]] || {
echo "Unrecognized OS_DISTRO: '${OS_DISTRO}'"
exit -1
}
[[ ! -e "Dockerfile.solution.${SOLUTION_SUFFIX}" ]] && {
SOLUTION_SUFFIX=""
}
;;
esac
[[ ! -e "Dockerfile${SOLUTION_SUFFIX}" ]] && {
cat << EOF
'${OS_DISTRO}' set as OS_DISTRO, but Dockerfile${SOLUTION_SUFFIX} does
not exist.
Using Dockerfile instead.
EOF
SOLUTION_SUFFIX=""
}
export DOCKERFILE="Dockerfile${SOLUTION_SUFFIX}"
export SOLUTION="Dockerfile.solution${SOLUTION_SUFFIX}"
echo "Building '${SOLUTION}' image from '${DOCKERFILE}'"
docker build -t ${CONTAINER}:${TAG} -f ${DOCKERFILE} . $* || {
cat << EOM
Building docker image from ${DOCKERFILE} failed.
EOM
exit -1
}
docker tag ${CONTAINER}:${TAG} ${CONTAINER} || {
echo "Unable to tag docker image"
exit -1
}
cat << EOM
${DOCKERFILE} was built and locally tagged as ${CONTAINER}:${TAG}
See 'scripts/push-image.sh' for information on pushing this tag to Harbor.
EOM