git-lfs/docker/build_dockers.bsh
2015-07-31 17:18:15 -04:00

40 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
# Usage:
# ./build_dockers.bsh - Build all the compiling docker images
# ./build_dockers.bsh lfs_centos_5 lfs_centos_7 - Build only CentOS 5 & 7 image
#
# Special Environment Variables
# DOCKER_LFS_BUILD_VERSION - tag or sha to build envirnment off of. Important
# in CentOS
set -eu
CUR_DIR=$(dirname "${BASH_SOURCE[0]}")
#If you are not in docker group and you have sudo, default value is sudo
: ${SUDO=`if ( [ ! -w /var/run/docker.sock ] && id -nG | grep -qwv docker && [ "${DOCKER_HOST:+dh}" != "dh" ] ) && which sudo > /dev/null 2>&1; then echo sudo; fi`}
export DOCKER_LFS_BUILD_VERSION=${DOCKER_LFS_BUILD_VERSION:-v0.5.4}
if [[ $# == 0 ]]; then
IMAGE_NAMES=($(ls -d ${CUR_DIR}/git-lfs_*.dockerfile))
else
IMAGE_NAMES=("${@}")
fi
#This will take a long time the first time
for IMAGE_NAME in "${IMAGE_NAMES[@]}"; do
NAME=$(basename ${IMAGE_NAME%.*})
#If you do decide to use the same key for all, this makes it easier. Only
#creates keys for git-lfs_* images, none of the others should be signing.
if [[ "${NAME}" == git-lfs_* ]] && [ ! -e ${CUR_DIR}/${NAME}.key ]; then
touch ${CUR_DIR}/${NAME}.key
fi
echo Docker building ${NAME}
${CUR_DIR}/docker+.bsh ${IMAGE_NAME} > ${CUR_DIR}/tmp.dockerfile
$SUDO docker build -t git-lfs/${NAME} -f ${CUR_DIR}/tmp.dockerfile ${CUR_DIR}
rm ${CUR_DIR}/tmp.dockerfile
done