2
0

dockerized.sh 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (c) 2008-2019 the Urho3D project.
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. # THE SOFTWARE.
  22. #
  23. if [[ $# -eq 0 ]]; then echo "Usage: dockerized.sh native|mingw|android|rpi|arm|web [command [params]]"; exit 1; fi
  24. PROJECT_DIR=$(cd ${0%/*}/..; pwd)
  25. if [[ ! $DBE_TAG ]]; then
  26. DBE_TAG=$(git describe --exact-match 2>/dev/null)
  27. # If the command failed or not on a tag then use 'master' by default
  28. if [[ $? -ne 0 ]]; then DBE_TAG=master; fi
  29. fi
  30. BuildEnvironment=-$1; shift
  31. BuildEnvironment=${BuildEnvironment/-base}
  32. # Workaround Travis-CI intermittent network I/O error
  33. if [[ $TRAVIS ]]; then while (! docker pull urho3d/dockerized$BuildEnvironment); do sleep 10; done; fi
  34. if [[ $(docker version -f {{.Client.Version}}) =~ ^([0-9]+)\.0*([0-9]+)\. ]] && (( ${BASH_REMATCH[1]} * 100 + ${BASH_REMATCH[2]} >= 1809 )); then
  35. docker run -it --rm -h fishtank \
  36. -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) -e PROJECT_DIR=$PROJECT_DIR \
  37. --env-file $PROJECT_DIR/script/.env-file \
  38. --mount type=bind,source=$PROJECT_DIR,target=$PROJECT_DIR \
  39. --mount source=$(id -u).urho3d_home_dir,target=/home/urho3d \
  40. --name dockerized$BuildEnvironment \
  41. urho3d/dockerized$BuildEnvironment:$DBE_TAG $@
  42. else
  43. # Fallback workaround on older Docker CLI version
  44. docker run -it --rm -h fishtank \
  45. -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) -e PROJECT_DIR=$PROJECT_DIR \
  46. --env-file <(perl -ne 'chomp; print "$_\n" if defined $ENV{$_}' $PROJECT_DIR/script/.env-file) \
  47. --mount type=bind,source=$PROJECT_DIR,target=$PROJECT_DIR \
  48. --mount source=$(id -u).urho3d_home_dir,target=/home/urho3d \
  49. --name dockerized$BuildEnvironment \
  50. urho3d/dockerized$BuildEnvironment:$DBE_TAG $@
  51. fi
  52. # vi: set ts=4 sw=4 expandtab: