You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.3 KiB

  1. #!/bin/sh
  2. set +x
  3. set -e
  4. : "${CCG_DOCKER_ORG:=muccg}"
  5. : "${CCG_COMPOSER:=ccg-composer}"
  6. : "${CCG_COMPOSER_VERSION:=latest}"
  7. : "${CCG_PIP_PROXY=0}"
  8. : "${CCG_HTTP_PROXY=0}"
  9. export CCG_DOCKER_ORG CCG_COMPOSER CCG_COMPOSER_VERSION CCG_PIP_PROXY CCG_HTTP_PROXY
  10. # ensure we have an .env file
  11. ENV_FILE_OPT=''
  12. if [ -f .env ]; then
  13. ENV_FILE_OPT='--env-file .env'
  14. set +e
  15. . ./.env > /dev/null 2>&1
  16. set -e
  17. else
  18. echo ".env file not found, settings such as project name and proxies will not be set"
  19. fi
  20. # Pass through the ip of the host if we can
  21. # There is no docker0 interface on Mac OS, so don't do any proxy detection
  22. if [ "$(uname)" != "Darwin" ]; then
  23. set +e
  24. DOCKER_ROUTE=$(ip -4 addr show docker0 | grep -Po 'inet \K[\d.]+')
  25. set -e
  26. export DOCKER_ROUTE
  27. fi
  28. TTY_OPTS=
  29. if [ -t 0 ]; then
  30. TTY_OPTS='--interactive --tty'
  31. fi
  32. ENV_OPTS="$(env | sort | cut -d= -f1 | grep "^CCG_[a-zA-Z0-9_]*$" | awk '{print "-e", $1}')"
  33. # shellcheck disable=SC2086 disable=SC2048
  34. docker run --rm ${TTY_OPTS} ${ENV_FILE_OPT} \
  35. ${ENV_OPTS} \
  36. -v /etc/timezone:/etc/timezone:ro \
  37. -v /var/run/docker.sock:/var/run/docker.sock \
  38. -v "$(pwd)":"$(pwd)" \
  39. -v "${HOME}"/.docker:/data/.docker \
  40. -w "$(pwd)" \
  41. "${CCG_DOCKER_ORG}"/"${CCG_COMPOSER}":"${CCG_COMPOSER_VERSION}" \
  42. "$@"