docker-build.sh 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. # (c) 2014-2015 Freifunk Paderborn <maschinenraum@paderborn.freifunk.net>
  3. # check if we're in the container
  4. running_in_docker() {
  5. awk -F/ '$2 == "docker"' /proc/self/cgroup | read
  6. }
  7. # when called within the container, just call build.sh after ensuring git config is set
  8. if [ running_in_docker -a "$(id -un)" == "build" ]; then
  9. # ensure that we have a valid git config
  10. git config --global user.name "docker-based build"
  11. git config --global user.email build@paderborn.freifunk.net
  12. # invoke the actual build
  13. ./build.sh $@
  14. exit
  15. fi
  16. MYDIR="$(dirname $0)"
  17. MYDIR="$(readlink -f $MYDIR)"
  18. pushd "$MYDIR" > /dev/null
  19. # run the container with fixed hostname and mapped /code directory
  20. docker run -ti -h ffpb-build -v "$MYDIR:/code" \
  21. --env BUILD_TS="$BUILD_TS" \
  22. --env BASE="$BASE" \
  23. --env BRANCH="$BRANCH" \
  24. --env BROKEN="$BROKEN" \
  25. --env MAKEJOBS="$MAKEJOBS" \
  26. --env VERBOSE="$VERBOSE" \
  27. --env VERSION="$VERSION" \
  28. --env TARGETS="$TARGETS" \
  29. ffpb/build
  30. popd > /dev/null