docker-build.sh 888 B

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