docker-build.sh 962 B

123456789101112131415161718192021222324252627282930313233343536
  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 VERBOSE="$VERBOSE" \
  25. --env VERSION="$VERSION" \
  26. --env TARGETS="$TARGETS" \
  27. ffpb/build
  28. popd > /dev/null