docker-build.sh 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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 CLEAN="${CLEAN}" \
  28. --env KEY_DIR="${KEY_DIR}" \
  29. --env MAKEJOBS="${MAKEJOBS}" \
  30. --env PRIORITY="${PRIORITY}" \
  31. --env PUBLISH="0" \
  32. --env SITE_ID="${SITE_ID}" \
  33. --env TARGETS="${TARGETS}" \
  34. --env VERBOSE="${VERBOSE}" \
  35. ffpb/build
  36. popd > /dev/null #${MYDIR}