Mumble docker container
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.

69 lines
1.3 KiB

9 years ago
9 years ago
9 years ago
  1. #!/usr/bin/env bash
  2. set -o errexit
  3. ## PRE-RUN SETUP & CONFIGURATION
  4. ########################################
  5. SCRIPT_DIR="$(dirname $(readlink -f ${0}))"
  6. IMAGE_NAME="phlak/mumble"
  7. TAG="$(grep 'ARG MUMBLE_VERSION' Dockerfile | awk -F = '{print $2}')"
  8. ## SCRIPT USAGE
  9. ########################################
  10. function usageShort() {
  11. echo "Usage: $(basename ${0}) [OPTIONS]"
  12. }
  13. function usageLong() {
  14. usageShort
  15. cat <<-EOF
  16. OPTIONS:
  17. -h, --help Print this help dialogue
  18. -p, --purge Purge the image after build
  19. EOF
  20. }
  21. ## OPTION / PARAMATER PARSING
  22. ########################################
  23. PARSED_OPTIONS=$(getopt -n "${0}" -o hp -l "help,purge" -- "$@")
  24. eval set -- "${PARSED_OPTIONS}"
  25. while true; do
  26. case "${1}" in
  27. -h|--help) usageLong; exit ;;
  28. -p|--purge) PURGE=true; shift ;;
  29. --) shift; break ;;
  30. esac
  31. done
  32. ## SCRIPT FUNCTIONS
  33. ########################################
  34. function buildImage() {
  35. docker build --force-rm --pull --tag ${IMAGE_NAME}:${TAG} ${SCRIPT_DIR}
  36. }
  37. function purgeImage() {
  38. docker rmi --force ${IMAGE_NAME}:${TAG}
  39. echo "Purged image: ${IMAGE_NAME}:${TAG}"
  40. }
  41. function main() {
  42. buildImage; [[ "${PURGE}" == true ]] && purgeImage
  43. echo "Successfully built ${IMAGE_NAME}:${TAG}"
  44. }
  45. # MAKE IT SO
  46. ########################################
  47. main