2015-07-12 20:49:48 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
2015-09-10 15:46:33 +00:00
|
|
|
# Usage:
|
2015-07-19 22:59:14 +00:00
|
|
|
# ./build_dockers.bsh - Build all the compiling docker images
|
2015-07-17 17:07:00 +00:00
|
|
|
# ./build_dockers.bsh lfs_centos_5 lfs_centos_7 - Build only CentOS 5 & 7 image
|
2015-07-30 05:02:46 +00:00
|
|
|
#
|
|
|
|
# Special Environment Variables
|
2015-09-10 15:46:33 +00:00
|
|
|
# DOCKER_LFS_BUILD_VERSION - tag or sha to build envirnment off of. Important
|
2015-07-31 20:32:40 +00:00
|
|
|
# in CentOS
|
2015-07-12 20:49:48 +00:00
|
|
|
set -eu
|
|
|
|
|
|
|
|
CUR_DIR=$(dirname "${BASH_SOURCE[0]}")
|
|
|
|
|
2015-09-11 06:57:39 +00:00
|
|
|
: ${GOLANG_VERSION:=1.5.1}
|
|
|
|
export GOLANG_VERSION
|
|
|
|
|
2015-07-17 17:07:00 +00:00
|
|
|
#If you are not in docker group and you have sudo, default value is sudo
|
2015-07-25 01:54:12 +00:00
|
|
|
: ${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`}
|
2015-07-13 03:50:05 +00:00
|
|
|
|
2015-09-11 06:57:39 +00:00
|
|
|
export DOCKER_LFS_BUILD_VERSION=${DOCKER_LFS_BUILD_VERSION:-master}
|
2015-07-26 00:01:11 +00:00
|
|
|
|
2015-07-17 17:07:00 +00:00
|
|
|
if [[ $# == 0 ]]; then
|
2015-07-25 02:57:04 +00:00
|
|
|
IMAGE_NAMES=($(ls -d ${CUR_DIR}/git-lfs_*.dockerfile))
|
2015-07-17 17:07:00 +00:00
|
|
|
else
|
2015-07-25 02:57:04 +00:00
|
|
|
IMAGE_NAMES=("${@}")
|
2015-07-17 17:07:00 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
#This will take a long time the first time
|
2015-07-25 02:57:04 +00:00
|
|
|
for IMAGE_NAME in "${IMAGE_NAMES[@]}"; do
|
2015-07-27 23:53:26 +00:00
|
|
|
NAME=$(basename ${IMAGE_NAME%.*})
|
2015-09-10 15:46:33 +00:00
|
|
|
#If you do decide to use the same key for all, this makes it easier. Only
|
2015-07-30 05:02:46 +00:00
|
|
|
#creates keys for git-lfs_* images, none of the others should be signing.
|
2015-07-31 21:18:15 +00:00
|
|
|
if [[ "${NAME}" == git-lfs_* ]] && [ ! -e ${CUR_DIR}/${NAME}.key ]; then
|
|
|
|
touch ${CUR_DIR}/${NAME}.key
|
2015-07-30 05:02:46 +00:00
|
|
|
fi
|
2015-07-27 23:53:26 +00:00
|
|
|
|
|
|
|
echo Docker building ${NAME}
|
2015-08-16 15:18:45 +00:00
|
|
|
${CUR_DIR}/docker+.bsh ${IMAGE_NAME} > ${CUR_DIR}/Dockerfile
|
|
|
|
$SUDO docker build -t git-lfs/${NAME} ${CUR_DIR}
|
|
|
|
rm ${CUR_DIR}/Dockerfile
|
2015-07-12 20:49:48 +00:00
|
|
|
done
|