2
0

dockerized.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env bash
  2. #
  3. # Copyright (c) 2008-2018 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. BuildEnvironment=-$1; shift
  26. BuildEnvironment=${BuildEnvironment/-base}
  27. if [[ $(docker version -f {{.Client.Version}}) =~ ^([0-9]+)\.0*([0-9]+)\. ]] && (( ${BASH_REMATCH[1]} * 100 + ${BASH_REMATCH[2]} >= 1809 )); then
  28. docker run -it --rm -h fishtank \
  29. -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) \
  30. --env-file $PROJECT_DIR/.env-file \
  31. --mount type=bind,source=$PROJECT_DIR,target=/project_dir \
  32. --mount source=urho3d_home_dir,target=/home/urho3d \
  33. --name dockerized$BuildEnvironment \
  34. urho3d/dockerized$BuildEnvironment $@
  35. else
  36. # Fallback workaround on older Docker CLI version
  37. docker run -it --rm -h fishtank \
  38. -e HOST_UID=$(id -u) -e HOST_GID=$(id -g) \
  39. --env-file <(perl -ne 'chomp; print "$_=$ENV{$_}\n" if defined $ENV{$_}' $PROJECT_DIR/.env-file) \
  40. --mount type=bind,source=$PROJECT_DIR,target=/project_dir \
  41. --mount source=urho3d_home_dir,target=/home/urho3d \
  42. --name dockerized$BuildEnvironment \
  43. urho3d/dockerized$BuildEnvironment $@
  44. fi
  45. # vi: set ts=4 sw=4 expandtab: