docker-build.sh 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/bin/bash
  2. # (c) 2014-2016 Freifunk Hochstift <kontakt@hochstift.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@hochstift.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 ffho-build -v "${MYDIR}:/code" \
  21. --env BASE="${BASE}" \
  22. --env BRANCH="${BRANCH}" \
  23. --env VERSION="${VERSION}" \
  24. --env AUTOUPDATER="${AUTOUPDATER}" \
  25. --env BROKEN="${BROKEN}" \
  26. --env BUILD_TS="${BUILD_TS}" \
  27. --env DIRCLEAN="${DIRCLEAN}" \
  28. --env MAKEJOBS="${MAKEJOBS}" \
  29. --env PRIORITY="${PRIORITY}" \
  30. --env SITE_ID="${SITE_ID}" \
  31. --env TARGETS="${TARGETS}" \
  32. --env VERBOSE="${VERBOSE}" \
  33. ffpb/build
  34. popd > /dev/null #${MYDIR}