diff options
| author | Claus Strasburger <claus@strasburger.de> | 2017-08-31 19:26:05 +0200 |
|---|---|---|
| committer | XECDesign <XECDesign@users.noreply.github.com> | 2017-09-21 12:53:01 +0100 |
| commit | 732a87415d58705b6fac268e98ee9e5b0329f76e (patch) | |
| tree | 93d98ed9f904bad700d7868c2a8c905dc8cb01f9 | |
| parent | 9aa87dbfb4a9d6ec3e5796d8275a45e2d685e8d6 (diff) | |
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
| -rw-r--r-- | .dockerignore | 2 | ||||
| -rwxr-xr-x | build-docker.sh | 17 |
2 files changed, 12 insertions, 7 deletions
diff --git a/.dockerignore b/.dockerignore index 4b019f9..e7f7a4a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1,3 +1,5 @@ output/ work/ deploy/ +apt-cacher-ng/ +.git/objects/* diff --git a/build-docker.sh b/build-docker.sh index eabc8f7..64bb120 100755 --- a/build-docker.sh +++ b/build-docker.sh @@ -13,9 +13,9 @@ if ! $DOCKER ps >/dev/null; then fi set -e -config_mount=() +config_file=() if [ -f config ]; then - config_mount=("-v" "$(pwd)/config:/pi-gen/config:ro") + config_file=("--env-file" "$(pwd)/config") source config fi @@ -24,7 +24,7 @@ CONTINUE=${CONTINUE:-0} 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 fi cat >&2 <<EOF @@ -60,18 +60,21 @@ if [ "$CONTAINER_EXISTS" != "" ]; then bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && cd /pi-gen; ./build.sh; rsync -av work/*/build.log deploy/" & - wait + wait "$!" else trap "echo 'got CTRL+C... please wait 5s'; $DOCKER stop -t 5 ${CONTAINER_NAME}" SIGINT SIGTERM time $DOCKER run --name "${CONTAINER_NAME}" --privileged \ -e IMG_NAME=${IMG_NAME}\ - -v "$(pwd)/deploy:/pi-gen/deploy" \ - "${config_mount[@]}" \ + "${config_file[@]}" \ pi-gen \ bash -e -o pipefail -c "dpkg-reconfigure qemu-user-static && cd /pi-gen; ./build.sh && rsync -av work/*/build.log deploy/" & - wait + wait "$!" $DOCKER rm -v $CONTAINER_NAME 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/" |
