docker-build.sh 969 B

12345678910111213141516171819202122232425262728293031323334353637
  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. # build the container (TODO: remove this, it should get pulled from the hub)
  19. docker build -t ffpb/build docker
  20. # run the container with fixed hostname and mapped /code directory
  21. docker run -ti -h ffpb-build -v "$MYDIR:/code" \
  22. --env BUILD_TS="$BUILD_TS" \
  23. --env BASE="$BASE" \
  24. --env BRANCH="$BRANCH" \
  25. --env VERBOSE="$VERBOSE" \
  26. --env VERSION="$VERSION" \
  27. ffpb/build
  28. popd > /dev/null