Ensure extra config file is passed to docker

Fixes #253

Rather than use --env-file, which gets overwritten by the regular config file, pass the any arguments to build-docker.sh through to build.sh.
pull/255/head
Sam Tygier 2019-02-16 14:59:32 +00:00 committed by XECDesign
parent 9e6af47045
commit c147df99bc
1 changed files with 5 additions and 10 deletions

View File

@ -1,5 +1,7 @@
#!/bin/bash -e #!/bin/bash -e
BUILD_OPTS="$@"
DOCKER="docker" DOCKER="docker"
set +e set +e
$DOCKER ps >/dev/null 2>&1 $DOCKER ps >/dev/null 2>&1
@ -13,9 +15,7 @@ if ! $DOCKER ps >/dev/null; then
fi fi
set -e set -e
config_file=()
if [ -f config ]; then if [ -f config ]; then
config_file=("--env-file" "$(pwd)/config")
source config source config
fi fi
@ -23,9 +23,7 @@ while getopts "c:" flag
do do
case "$flag" in case "$flag" in
c) c)
EXTRA_CONFIG="$OPTARG" source "$OPTARG"
config_file=( "${config_file[@]}" "--env-file" "$(pwd)/${EXTRA_CONFIG}")
source "$EXTRA_CONFIG"
;; ;;
esac esac
done done
@ -58,20 +56,17 @@ if [ "$CONTAINER_EXISTS" != "" ]; then
trap "echo 'got CTRL+C... please wait 5s'; $DOCKER stop -t 5 ${CONTAINER_NAME}_cont" SIGINT SIGTERM trap "echo 'got CTRL+C... please wait 5s'; $DOCKER stop -t 5 ${CONTAINER_NAME}_cont" SIGINT SIGTERM
time $DOCKER run --rm --privileged \ time $DOCKER run --rm --privileged \
--volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \ --volumes-from="${CONTAINER_NAME}" --name "${CONTAINER_NAME}_cont" \
-e IMG_NAME="${IMG_NAME}"\
pi-gen \ pi-gen \
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
cd /pi-gen; ./build.sh; cd /pi-gen; ./build.sh ${BUILD_OPTS} ;
rsync -av work/*/build.log deploy/" & rsync -av work/*/build.log deploy/" &
wait "$!" wait "$!"
else else
trap "echo 'got CTRL+C... please wait 5s'; $DOCKER stop -t 5 ${CONTAINER_NAME}" SIGINT SIGTERM trap "echo 'got CTRL+C... please wait 5s'; $DOCKER stop -t 5 ${CONTAINER_NAME}" SIGINT SIGTERM
time $DOCKER run --name "${CONTAINER_NAME}" --privileged \ time $DOCKER run --name "${CONTAINER_NAME}" --privileged \
-e IMG_NAME="${IMG_NAME}"\
"${config_file[@]}" \
pi-gen \ pi-gen \
bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static &&
cd /pi-gen; ./build.sh && cd /pi-gen; ./build.sh ${BUILD_OPTS} &&
rsync -av work/*/build.log deploy/" & rsync -av work/*/build.log deploy/" &
wait "$!" wait "$!"
fi fi