Docker-Build enhancements

- don't use any volume mounts anymore to allow using docker-in-docker
(with docker.sock mounted)
- smaller Docker build context by ignoring some files
pull/113/head
Claus Strasburger 2017-08-31 19:26:05 +02:00 committed by XECDesign
parent 9aa87dbfb4
commit 732a87415d
2 changed files with 12 additions and 7 deletions

View File

@ -1,3 +1,5 @@
output/ output/
work/ work/
deploy/ deploy/
apt-cacher-ng/
.git/objects/*

View File

@ -13,9 +13,9 @@ if ! $DOCKER ps >/dev/null; then
fi fi
set -e set -e
config_mount=() config_file=()
if [ -f config ]; then if [ -f config ]; then
config_mount=("-v" "$(pwd)/config:/pi-gen/config:ro") config_file=("--env-file" "$(pwd)/config")
source config source config
fi fi
@ -24,7 +24,7 @@ CONTINUE=${CONTINUE:-0}
if [ "$*" != "" ] || [ -z "${IMG_NAME}" ]; then if [ "$*" != "" ] || [ -z "${IMG_NAME}" ]; then
if [ -z "${IMG_NAME}" ]; then if [ -z "${IMG_NAME}" ]; then
echo "IMG_NAME not set in 'build'" 1>&2 echo "IMG_NAME not set in 'config'" 1>&2
echo 1>&2 echo 1>&2
fi fi
cat >&2 <<EOF cat >&2 <<EOF
@ -60,18 +60,21 @@ if [ "$CONTAINER_EXISTS" != "" ]; then
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;
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}\ -e IMG_NAME=${IMG_NAME}\
-v "$(pwd)/deploy:/pi-gen/deploy" \ "${config_file[@]}" \
"${config_mount[@]}" \
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 &&
rsync -av work/*/build.log deploy/" & rsync -av work/*/build.log deploy/" &
wait wait "$!"
$DOCKER rm -v $CONTAINER_NAME $DOCKER rm -v $CONTAINER_NAME
fi fi
echo "copying results from deploy/"
$DOCKER cp "${CONTAINER_NAME}":/pi-gen/deploy .
ls -lah deploy
echo "Done! Your image(s) should be in deploy/" echo "Done! Your image(s) should be in deploy/"